Monday, November 2, 2009
Q1. (a) What do you understand by Function Overloading in C++? Explain with example.
(b) What is Unary Operator Overloading? Explain with example.
Q2. (a) Write short note on Inheritance and its types.
(b) Write a program in C++ to implement hierarchical inheritance.
Q3. (a) Write short note on container class and tokens.
(b) Write short note on the following with example (1) Private (2) Public
(3) Protected
****
Q1. a. how is the access control thru derivation different from friendship?
b. how r ststic members different frm non static members?
Q.2 (a) What is an Object and how objects can be defined in C++?
(b) Compare early binding and late binding. When virtual functions are created for
implementing late binding what basic rule should be observed?
Q3. (a) What is a stream? Describe briefly the features of Input /Output stream supported
by C++.
(b) What is Inline function? Discuss the advantages and disadvantages of it.
Q4. (a) Write short note on Constructor & Destructor.
(b) Explain briefly about function prototype with examples.
Q1. Write a prog to implement a class complex wich overload +operator to add 2 complex numbers.
Q2. When does ambiguity arise in inheritence?
Q3. How r foll constructors difrnt frm one anoter?
a. Parameterised constructor.
b. Default constructor
c. constructor with default arguements.
Q1. Relate object and class in OOP.
Q2. Diff bet data type struct and data type class in C++.
Q3. Diff bet private and protected members.
Q4. What do destructors do? Is it necessary to hav destructor for a class.?
Q5. How can private members of a class be made inheritable?
Q6. What is a friend class? is it different from a friend function?
Wednesday, August 26, 2009
C Language Project
// BY PUNEET SHARMA
#include < stdio.h >
#include < conio.h >
#include < dos.h >
#include < process.h >
struct Student
{
int rollno;
char name[20];
int fee;
};
struct Student a;
void getData()
{ printf("\n\nEnter the data for the student:");
//fflush(stdin);
fflush(stdin);
puts(" \n Name : "); gets(a.name);
puts(" roll no:");
scanf("%d",&a.rollno);
printf("Fee:");
scanf("%d",&(a.fee));
}
void printData(struct Student a)
{
printf("\n%s","Name : " ); printf("%s",a.name);
printf("\n%s","Rollno : "); printf("%d",a.rollno);
printf("\n%s","Fee : "); printf("%d",a.fee);
}
void showAll()
{
FILE *fp;
char c;
clrscr();
printf("\n\n\n\n\n\t\t\t%5s|","Roll No.");
printf(" %-10s |", "Name");
printf("%6s","Fee");
printf("\n\t\t\t--------|--------------|------");
fp=fopen("student.txt","r");
rewind(fp);
while ((c=getc(fp)) != EOF)
{ fscanf(fp,"%d %s %d",&a.rollno,a.name,&a.fee);
printf("\n\t\t\t%5d | ",a.rollno);
printf("%-10s |",a.name);
printf("%6d",a.fee);
}
getche();
fclose(fp);
}
void showRec()
{
int i,z=0,j=0,n=0;
char c;
FILE *fp1;
clrscr();
z=sizeof(struct Student);
fp1=fopen("student.txt","r");
printf(" \n\n Enter the record no. you want to see : ");
scanf ("%d",&i) ;
rewind(fp1);
while(1)
{ c = getc(fp1);
if(c=='$')
j++;
if(j==i)
{
fscanf(fp1,"%d %s %d",&a.rollno,a.name,&a.fee);
printData(a);
break;
}
if(c==EOF)
break;
}
if(j!=i)
printf("\n\n\t\tSorry, Record not found in database.");
fclose(fp1);
getche();
}
void modifyRec()
{ char ch,res;
int i=0,j=0;
FILE *fp,*fp2;
clrscr();
fp=fopen("student.txt","r");
fp2=fopen("student1.txt","w");
flushall();
printf("\nEnter the record no. you want to modify: ");
scanf("%d",&i);
while(1)
{ ch = getc(fp);
if(ch=='$')
j++;
if(j==i)
{
fscanf(fp,"%d %s %d",&a.rollno,a.name,&a.fee);
printData(a);
flushall();
printf("\n\nModify this record(Y/N): ");
scanf("%c",&res);
if(res=='Y' || res=='y')
{
flushall();
ch = getc(fp);
if(ch=='$'||ch==EOF)
j++;
getData();
flushall();
flushall();
fprintf(fp2,"%c %d %s %d",'$',a.rollno,a.name,a.fee);
}
else
goto th;
}
if(ch==EOF)
break;
else
fputc(ch,fp2);
}
fclose(fp2);
fclose(fp);
fp=fopen("student.txt","w");
fp2=fopen("student1.txt","r");
ch=NULL;
while(1)
{
ch=getc(fp2);
if(ch==EOF)
break;
else
fputc(ch,fp);
}
th:
fclose(fp);
fclose(fp2);
}
void addRec()
{
FILE *fp1;
char c;
int i=0;
fp1 = fopen ("student.txt","a");
if (fp1 == NULL )
{ puts ("Internal Error: File cannot be opened." ) ;
getche();
exit(0);
}
clrscr();
printf( "\n\t%c",201);
while(i++<40)
printf( "%c",205);
printf( "%c",187);
printf ( " \n\t%c\tRoll No.: ",186 );
scanf ("%d",&a.rollno);
printf ( " \n\t\tName: " );
scanf ("%s",a.name);
printf ( " \n\t\tFee: " );
scanf ("%d",&a.fee);
fprintf(fp1,"%c",'$');
fprintf(fp1,"%d %s %d",a.rollno,a.name,a.fee);
fclose(fp1);
}
void delRec()
{
FILE *fp,*fp2;
int j=0,d,i=0;
char ch,res=NULL;
fp=fopen("student.txt","r");
fp2=fopen("student1.txt","w");
clrscr();
printf("\nEnter the record no. you want to delete: ");
scanf("%d",&i);
while(1)
{ ch = getc(fp);
if(ch=='$')
j++;
if(j==i)
{
fscanf(fp,"%d %s %d",&a.rollno,a.name,&a.fee);
printData(a);
flushall();
printf("\n\nDelete this record(Y/N): ");
scanf("%c",&res);
if(res=='Y' || res=='y')
{
flushall();
ch = getc(fp);
if(ch=='$'||ch==EOF)
j++;
flushall();
}
else
goto th;
}
if(ch==EOF)
break;
else
fputc(ch,fp2);
}
fclose(fp2);
fclose(fp);
fp=fopen("student.txt","w");
fp2=fopen("student1.txt","r");
ch=NULL;
while(1)
{
ch=getc(fp2);
if(ch==EOF)
break;
else
fputc(ch,fp);
}
th:
fclose(fp);
fclose(fp2);
}
void main()
{ char name[20];
int i=15 ; char ch;
do { clrscr();i=5;
while(i!=0){printf("\n"); i--; }
printf( "\n\t\t%c",201);i=0;
while(i++<42) printf( "%c",205);
printf( "%c",187);
printf ( " \n\t\t%c\t 1 . Show All Records %12c",186,186 );
printf ( " \n\t\t%c\t 2 . Add New Record %14c",186,186);
printf ( " \n\t\t%c\t 3 . Modify a Record %13c",186,186);
printf ( " \n\t\t%c\t 4 . Search Records %14c",186,186 );
printf ( " \n\t\t%c\t 5 . Delete Record %15c",186,186 );
printf ( "\n\t\t%c\t Esc . Exit %24c",186,186 );
printf("\n\t\t%c",200);
i=0;
while(i++<42) printf( "%c",205);
printf("%c",188);
printf ( " \n\n\n\t\t\t Enter your Choice : " );
//scanf ("%d",&i);
fflush(stdin);
ch = getch();
if (ch==27){ ch=54; }// exit(-1) ;
switch(ch-48)
{ case 1 : showAll () ; break;
case 2 : addRec () ; break;
case 3 : modifyRec() ; break;
case 4 : showRec(); break;
case 5 : delRec () ; break;
case 6 :
{printf("\n\n\t\tApplication will terminate itself in 3 seconds.");
delay(1000);printf("...3");
delay(1000);printf("..2");
delay(1000);printf(".1");
delay(500);printf(" ");
exit(0);
}
}
} while ( ((ch-48)>=1) && ( (ch-48)<=6 ));
}
Friday, July 31, 2009
To calculate sum of digits
#include
#include
//To calculate sum of digits
int sum( int k)
{ if (k<10) return k;
else return ( ( k%10) + sum( k/10) ) ;
}
void main()
{
int i,j; char src[20],find [20] , ch;
clrscr();
printf("Enbter number " ); scanf("%d" , &i);
j = sum(i);
printf( "Sum is : %d ", j);
getch();
}
To toggle character
#include
#include
//To toggle character
char toggle(char);
void main()
{
char arr[16];
int c,i; char a;
clrscr();
scanf("%s" , arr);
for(i=0;arr[i]!='\0';i++)
{
a= toggle(arr[i]) ;
printf("%c",a);
}
}
char toggle(char c)
{
if(c>=65 && c<=122)
{
if(c>=97)
return(c-32);
else
return(c+32);
}
}
Factorial
#include
#include
//To calculate factorial of a no
{
if (i==1)return 1 ;
else return( i* factorial(i-1)) ;
}
int sumdigit(int i )
{
if (i<=0) return 0 ; else return( i%10 + sumdigit(i/10) ) ; } void main() { printf("\n%d " , factorial(5) ) ; printf("\n%d " , sumdigit(31564) ) ; getch(); }
Reverse Three digit no.
#include < stdio.h >
#include < conio.h >
//reverse three digit no
void main()
{
int a,b,r;
clrscr();
printf("Enter 3 digit no=");
scanf("%d",&a);
r=a%10;
b=r*100;
a=a/10;
r=a%10;
b=b+r*10;
a=a/10;
b=b+a;
printf("Result is %d",b);
getch();
}
Thursday, July 30, 2009
Robowars
Robowars is an Inter College Competition. Only one team is allowed per institute.
For registration you have to send an official confirmation either through e-mail to robowars@techfest.org or a fax to 022 2572 3480 signed by a competent authority of your institute (By competent authority we mean either the head of the institute or the head of the student affairs of the institute). Once we receive the signed copy the name of the institute would be put up on the website.
To see the participating colleges till date, click link below.
The Blood....the sweat.... the fire..... the glory....

Flying blades, violent flame throwers, the thrashing sound of metal and a junk pile of annihilated machines, welcome to the world of combat robotics. Techfest 2009 brings you Robowars- the inter college combat robotics competition, a modern day Colosseum for the next generation of war machines, the battle for supremacy can never get bigger than this.
This is what we call -- mortal combat.
1. Problem Statement
Design and construct a remote controlled combat robot for a one on one knockout tournament.
Prizes worth INR 45,000 to be won.
View the Machine Specifications »
For further queries :
Log on to : http://techfest.org/archives/tf09/competitions/robowars/
Contact :
Agyeya SharmaManager, Robowars | Sidharth MishraManager, Robowars |
Wednesday, July 29, 2009
Next-gen electric cars to swap lithium-air-based batteries

I guess you all use cellphones and are quite familiar with refill, recharging via coupon rather, and all. Imagine recharging your vehicles in the same way when they run high and dry. Well, it is no viewing through rose-tinted glasses since Japanese scientists are thinking seriously about a cassette refill system for the next-gen electric cars. Relying on newly developed lithium-air cells, they can do it!