MOTOROLA SCHOLAR PROGRAM : 2011-12


Dear All,

MOTOROLA SCHOLAR PROGRAM : 2011-12
Website : www.faer.ac.in

FAER announces the Motorola Scholar program to select scholars from engineering colleges based on a project work in the areas of

1) Computer Science and IT

2) Communications

3) Renewable Energy Systems

4) resources

5) Rural technologies

6) Health care Technologies

7) Labour saving Technologies for Women

8) Ecology and Environment 9) Applications.

Selections will be done by Foundation for Advancement for Education and Research (FAER). It consists of two stages.

Stage 1 : FAER will receive project proposals from students in engineering colleges, screen them with the help of experts and select projects for
funding. An amount to a maximum of Rs. 5000/- will be reimbursed to the project team after their completion of the project.

Stage 2 : Selection of “Motorola Scholars” based on the evaluation of the completed projects through a Seminar-cum-Exhibition and best projects will be awarded with Cash Prize and Certificates in Motorola Scholar Awards Presentation Function.

There will be a special award for students from disadvantaged sections.

Last date for receipt of hardcopy of the proposals for projects : 15th December 2011

Project Approvals by FAER : 16th February 2012

Prizes:

First Prize : Rs. 1,00,000/-
Second Prize : Rs. 75,000/-
Third Prize : Rs. 50,000/-
Special Award : Rs. 25,000/-

Bonafide students doing B.E. / M.C.A. courses in final year are eligible to participate in this contest. Students should be studying in a
recognized college / institute / university.

For further details, format for submitting project proposals please visit FAER website.

Foundation for Advancement of Education and Research
G5, Swiss Complex, 33, Race Course Road, Bangalore- 560001
E-mail: office@faer.ac.in , Website: www.faer.ac.in

Best Wishes!

Working with Database in VB6.0 without using Data Control


Basically, the novice users will use the data control to connect the data base with VB6.0. There are many different ways to connect with the database in VB6.0

The objective of this post is to explain the easy way to connect to Access database without using data control. To do that follow the steps:

  1. Design a form as shown below:

  2. Open the Visual Data Manager from your VB Project

  3. The Visual Data Manager will appear on the screen

  4. Create a new Access Database

  5. Save the database in a location where you have saved your VB Project. (i.e. VB Project and the Database should be in the same folder-only for this post)

  6. Right click on the database window and click “Create Table”

  7. Give a name for your table

  8. Then click “Add Field” Button to add the fields for your table

  9. Once you created all the fields, click OK button. Then click “Build the Table” Button.

  10. Once the table is created, click the “Dynaset type Recordset” , the second icon in the toolbar.

  11. Then click the “Use Data Control on New Form” , the fourth icon in the toolbar.

  12. The double click on the “stu”, table icon in the Database window. And you will get following input screen.

  13. Now, you can add data to your table. Once you entered press the “Close” Button.

Coding Part:

  1. Go to the General declaration area of your coding window. In that type the following:

    Dim dbStu As Database

    Dim rsStu As Recordset

    Dim Add As String

  2. Go to the Form_Load() event. In that type the following:

    Private Sub Form_Load()

    Set dbStu = OpenDatabase(App.Path & “\student.mdb”)

    Set rsStu = dbStu.OpenRecordset(“Select * from stu “)

    End Sub

  3. Go to the Click() event of the AddNew Button and type the following:

    Add = “Insert into stu values(‘” & Text1 & “‘, ‘” & Text2 & “‘,'” & Text3 & “‘,” & Val(Text4) & “,” & Val(Text5) & “)”

    dbStu.Execute Add

    Call Clear

  4. Go to the Click() event of the Update Button and type the following:

    Set rsStu = dbStu.OpenRecordset(“Select * from stu where rno = ‘” & Text1 & “‘”) ‘Search the stu table for given roll number in the Text1 text box.

    If rsStu.RecordCount = 0 Then

    MsgBox “No Record Found”

    Else

    rsStu.Edit     ‘Activating Edit Mode

    rsStu(0) = Text1

    rsStu(1) = Text2

    rsStu(2) = Text3

    rsStu(3) = Val(Text4)

    rsStu(4) = Val(Text5)

    rsStu.Update

    Call Clear

    End If

    If Not rsStu Is Nothing Then

    Set rsStu = Nothing

    End If

  5. Go to the Click() event of the Delete button and type the following:

    rsStu.Delete

    Call Clear

  6. Go to the Click() event of the Find button and type the following:

    strName = InputBox(“Enter Student Name…”, “Input Required”)

    Set rsStu = dbStu.OpenRecordset(“Select * from stu where name = ‘” & strName & “‘”)

    If rsStu.EOF = True Then

    MsgBox “No Record Found”

    Else

    Text1 = rsStu(0)

    Text2 = rsStu(1)

    Text3 = rsStu(2)

    Text4 = rsStu(3)

    Text5 = rsStu(4)

    End If

    If Not rsStu Is Nothing Then

    Set rsStu = Nothing

    Else

    rsStu.Close

    End If

  7. Go to the Click() event of the Clear Button and type the following:

    Call Clear

    This will call the Clear function, which should be defined first. The code is given below:

    Sub Clear()

    Text1.Text = “”

    Text2.Text = “”

    Text3.Text = “”

    Text4.Text = “”

    Text5.Text = “”

    If Not rsStu Is Nothing Then

    Set rsStu = Nothing

    Else

    rsStu.Close

    End If

    End Sub

  8. Go to the Click() event of the MoveFirst button and type the following:

    If rsStu Is Nothing Then

    Set rsStu = dbStu.OpenRecordset(“Select * from stu “)

    End If

    rsStu.MoveFirst

    Call LoadText

  9. Go to the Click() event of the MovePrevious button and type the following:

    If rsStu Is Nothing Then

    Set rsStu = dbStu.OpenRecordset(“Select * from stu “)

    End If

    On Error GoTo X:

    rsStu.MovePrevious

    If rsStu.BOF = False Then

    Call LoadText

    Else

    MsgBox “Reached First Record of the Table”, vbInformation, “First Record”

    End If

    X:

    ‘Display the error

  10. Go to the Click() event of the MoveNext button and type the following:

    On Error GoTo X:

    If rsStu Is Nothing Then

    Set rsStu = dbStu.OpenRecordset(“Select * from stu “)

    End If

    rsStu.MoveNext

    If rsStu.EOF = False Then

    Call LoadText

    Else

    MsgBox “Reached Last Record of the Table”, vbInformation, “Last Record”

    End If

    X:

    ‘Display the error

  11. Go to the Click() event of the MoveLast button and type the following:

    If rsStu Is Nothing Then

    Set rsStu = dbStu.OpenRecordset(“Select * from stu “)

    End If

    rsStu.MoveLast

    Call LoadText

  12. Create the LoadText() function with the following code:

    Text1 = rsStu(0)

    Text2 = rsStu(1)

    Text3 = rsStu(2)

    Text4 = rsStu(3)

    Text5 = rsStu(4)

  13. Press F5 to execute the program.

OOAD – Unit 1 Notes – B.E. CSE (Anna University of Technology, Tirunelveli)


Notes : OOAD – Unit 1

OOAD – Unit 1 Notes – Download ——->Unit I OOAD

Government Funded Project for Students


No end-date for this scheme…

It is an on-going scheme for the students…

Application Link:

http://www.cdc.org.in/schemes/fellowship.aspx

C code for Travelling Sales Person Problem – Branch and Bound Approach


/*Branch and Bound Algorithm for Travelling Sales Person*/

#include<stdio.h>

#include<conio.h>

int a[10][10],visited[10],n,cost=0;


void get()

{

int i,j;

printf(“Enter No. of Cities: “);

scanf(“%d”,&n);

printf(“\nEnter Cost Matrix: \n”);

for( i=0;i<n;i++)

{

printf(“\n Enter Elements of Row # : %d\n”,i+1);

for( j=0;j<n;j++)

scanf(“%d”,&a[i][j]);

visited[i]=0;

}

printf(“\n\nThe cost list is:\n\n”);

for( i=0;i<n;i++)

{

printf(“\n\n”);

for( j=0;j<n;j++)

printf(“\t%d”,a[i][j]);

}

}


void mincost(int city)

{

int i,ncity;

visited[city]=1;

printf(“%d –>”,city+1);

ncity=least(city);

if(ncity==999)

{

ncity=0;

printf(“%d”,ncity+1);

cost+=a[city][ncity];

return;

}

mincost(ncity);

}


int least(int c)

{

int i,nc=999;

int min=999,kmin;

for(i=0;i<n;i++)

{

if((a[c][i]!=0)&&(visited[i]==0))

if(a[c][i]<min)

{

min=a[i][0]+a[c][i];

kmin=a[c][i];

nc=i;

}

}

if(min!=999)

cost+=kmin;

return nc;

}


void put()

{

printf(“\n\nMinimum cost:”);

printf(“%d”,cost);

}

void main()

{

clrscr();

get();

printf(“\n\nThe Path is:\n\n”);

mincost(0);

put();

getch();

}

Input Sample:

No. of Nodes : 6

Cost Matrix:

99            10            15            20            99            8

5              99            9              10            8              99

6              13            99            12            99            5

8              8              9              99            6              99

99            10            99            6              99            99

10            99            5              99            99            99

C Code for Knapsack Problem using Backtracking Approach


/* knapsack  problem using backtracking*/

/* Variable Description….

n   – Total no. of items available

w[] – Weight of each item

p[] – Profit of each item

m   – Maximum Capacity of the Sack

unit[] – Profit of each item per Unit p[]/w[]

x[] – Final list of items put into the Sack

y[] – Intermediate list of selected items

fp  – Final Profit

fw  – Final Weight

cp  – Current Profit

cw  – Current Weight

*/

#include <stdio.h>

#include <conio.h>

#define max 10

int w[max],i,j,p[max];

int n,m;

float unit[max];

int y[max],x[max],fp=-1,fw;

void get()

{

printf(“\n Enter total number of items: “);

scanf(“%d”,&n);

printf(“\n Enter the Maximum capacity of the Sack: “);

scanf(“%d”,&m);

for(i=0;i<n;i++)

{

printf(“\n Enter the weight of the item # %d : “,i+1);

scanf(“%d”,&w[i]);

printf(“\n Enter the profit of the item # %d : “, i+1);

scanf(“%d”, &p[i]);

}

}

void show()

{

float s=0.0;

printf(“\n\tItem\tWeight\tCost\tUnit Profit\tSelected “);

for(i=0;i<n;i++)

printf(“\n\t%d\t%d\t%d\t%f\t%d”,i+1,w[i],p[i],unit[i],x[i]);

printf(“\n\n The Sack now holds following items : “);

for(i=0;i<n;i++)

if(x[i]==1)

{

printf(“%d\t”,i+1);

s += (float) p[i] * (float) x[i];

}

printf(“\n Maximum Profit: %f “,s);

}

/*Arrange the item based on high profit per Unit*/

void sort()

{

int t,t1;

float t2;

for(i=0;i<n;i++)

unit[i] = (float) p[i] / (float) w[i];

for(i=0;i<n-1;i++)

{

for(j=i+1;j<n;j++)

{

if(unit[i]  < unit[j])

{

t2 = unit[i];

unit[i] = unit[j];

unit[j] = t2;

t = p[i];

p[i] = p[j];

p[j] = t;

t1 = w[i];

w[i] = w[j];

w[j] =t1;

}

}

}

}

float bound(float cp,float cw,int k)

{

float b = cp;

float c = cw;

for(i=k;i<=n;i++)

{

c = c+w[i];

if( c < m)

b = b +p[i];

else

return (b+(1-(c-m)/ (float)w[i])*p[i]);

}

return b;

}

void knapsack(int k,float cp,float cw)

{

if(cw+w[k] <= m)

{

y[k] = 1;

if(k <= n)

knapsack(k+1,cp+p[k],cw+w[k]);

if(((cp+p[k]) > fp) && ( k == n))

{

fp = cp+p[k];

fw = cw+w[k];

for(j=0;j<=k;j++)

x[j] = y[j];

}

}

if(bound(cp,cw,k) >= fp)

{

y[k] = 0;

if( k <= n)

knapsack(k+1,cp,cw);

if((cp > fp) && (k == n))

{

fp = cp;

fw = cw;

for(j=0;j<=k;j++)

x[j] = y[j];

}

}

}

void main()

{

clrscr();

printf(“\n\n\n\t\t    ******** KNAPSACK PROBLEM ********”);

printf(“\n\t\t —————————————–“);

get();

printf(“\n The Sack is arranged in the order…\n”);

sort();

knapsack(0,0.0,0.0);

show();

getch();

}

Output:

******** KNAPSACK PROBLEM ********

——————————————-

Enter total number of items: 3

Enter the Maximum capacity of the Sack: 25

Enter the weight of the item # 1 : 1

Enter the profit of the item # 1 : 11

Enter the weight of the item # 2 : 11

Enter the profit of the item # 2 : 21

Enter the weight of the item # 3 : 21

Enter the profit of the item # 3 : 31

The Sack is arranged in the order…

Item    Weight     Cost    Unit Profit     Selected

1            1      11      11.000000          1

2            11     21      1.909091           0

3            21    31      1.476190           1

The Sack now holds following items : 1 3

Maximum Profit: 42.000000

Reference:

Computer Algorithms / C++ 2nd Edition by Ellis Horowitz, Sartaj Sahni and Sanguthevar Rajasekaran

Implementation of Randomized Quick Sort


/* Randomized Quick Sort */

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

int n;

void swap(int *a, int *b)

{

int x;

x = *a;

*a = *b;

*b = x;

}

void quicksort(int s[], int l, int h)

{

int p; /* index of partition */

if ((h – l) > 0) {

p = partition(s, l, h);

quicksort(s, l, p – 1);

quicksort(s, p + 1, h);

}

}

int partition(int s[], int l, int h)

{

int i;

int p; /* pivot element index */

int firsthigh; /* divider position for pivot element */

p = l + (random(n) % (h – l + 1));

swap(&s[p], &s[h]);

firsthigh = l;

for (i = l; i < h; i++)

if(s[i] < s[h]) {

swap(&s[i], &s[firsthigh]);

firsthigh++;

}

swap(&s[h], &s[firsthigh]);

 

return(firsthigh);

}

void main()

{

int s[20],i;

clrscr();

printf(“\nRandomized Quick Sort”);

printf(“\nEnter the no. of elements…”);

scanf(“%d”, &n);

printf(“\nEnter the elements one by one…”);

for(i=0;i<n;i++)

scanf(“%d”,&s[i]);

quicksort(s,0,n-1);

printf(“\nAfter sorting…\n”);

for(i=0;i<n;i++)

printf(“%d\t”,s[i]);

getch();

}