• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

C Assignments

Find prime numbers in C Language

July 7, 2013 by ProjectsGeek Leave a Comment

Prime numbers in C Language

Write a prime numbers in C Language program to generate prime numbers between 1 and n. User has to enter range of prime numbers and then program will print the prime numbers Between 1 to n.

prime numbers in C

We can find infinitely many prime numbers. Another way of saying this is that the sequence

2, 3, 5, 7, 11, 13, 17 ,19 and so on …… So you can find infinite number of prime Numbers.

Prime numbers in C Language Code

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i=0,j=0,c=0,n;
printf(“\nenter range for prime numbers:”);
scanf(“%d”,&n);
printf(“\n The prime numbers between 1 to %d are: \n”,n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
if(i%j==0)
c++;
}
if(c<=2)
printf(“%d “,i);
c=0;
}
getch();
}

 

Other Projects to Try:

  1. Fibonacci numbers program in C Language
  2. How to Implement Hash Table using C language
  3. Assembly Language Codes
  4. Multiply Two 8 Bit Numbers in Assembly Language
  5. GCD of Two Numbers program in Assembly Language

Filed Under: C Assignments

GCD of two integers Code in C Language

July 7, 2013 by ProjectsGeek Leave a Comment

GCD of two integers Code in C Language

Write a GCD of two integers program in C to compute the GCD of the given two integers .User need to enter two numbers a and b,which needs to be use to find GCD of two numbers.

You can take the example, the GCD(greatest common divisor) of 8 and 12 is 4.

GCD of two Numbers

GCD of two integers Code

#include<stdio.h>
int gcd(int a, int b);
int gcd_recurse(int a, int b);
int main()
{
int a,b;
clrscr();
printf(“\nenter two nos to caluculate GCD:”);
scanf(“%d%d”,&a,&b);
printf(“\nGCD(%2d,%2d) = [%d]“, a,b, gcd(a,b));
printf(“\nGCD(%2d,%2d) = [%d]“, a,b, gcd_recurse(a,b));
getch();
return(0);
}

int gcd(int a, int b)
{
int temp;
while(b)
{
temp = a % b;
a = b;
b = temp;
}
return(a);
}

int gcd_recurse(int a, int b)
{
int temp;
temp = a % b;
if (temp == 0)
{
return(b);
}
else
{
return(gcd_recurse(b, temp));
}
}

 

Other Projects to Try:

  1. N queen problem code in C Language
  2. Regular Expression to DFA Code in C Language
  3. Prims algorithm Code in C Language
  4. GCD of Two Numbers program in Assembly Language
  5. Assembly Language Codes

Filed Under: C Assignments

Banking project in c language source code

June 23, 2013 by ProjectsGeek 2 Comments

Banking  project in C Language

 

Statement : Develop a Banking  project in c language which will implement following features or functionality in the program .

 

  • Account Creation
  • Deposit Amount
  • Withdraw Amount
  • View Details
  • Foreign Exchange
  • Exit program

 


 #include<stdio.h>  
 #include<dos.h>  
 #include<conio.h>  
 #include<string.h>  
 #include<graphics.h>  
 #include<process.h>  
 struct bank // Bank Structure  
 {int accno;  
 char name[20];  
 float bal;  
 }b;  
 void main()  
 {int ch;  
 clrscr();  
 b:printf("\n\t\t\t\t Welcome to Aarthi Banking Corporation \n\n\n\t Please select your appropriate option...");  
 printf("\n 1. New customer \n 2. Existing customer \n 3. Exit");  
 scanf("%d",&ch);  
 switch (ch)  
 { case 1:  
      {FILE*ff;  
      ff=fopen("customer.dat","a");  
      clrscr();  
      printf("\n Welcome to Aarthi Banking Corporation (ABC.Ltd).\n It is a pleasure to have you here \n Please enter your name without spaces :");  
      scanf("%s",&b.name);  
      clrscr();  
      printf("\n Welcome %s, please enter a suitable account number",b.name);  
      scanf("%d",&b.accno);  
      printf("\n Please mention the initial deposit... Rs: ");  
      scanf("%f",&b.bal);  
      printf("\n Congratulations... Your account has been created.\nTo deposit please login as existing customer");  
      fwrite(&b,sizeof(b),1,ff);  
      fclose(ff);  
      getch();  
      clrscr();  
      goto b;  
      }break;  
 case 2:  
      {     int num,count=0,n,ch,flag;  
  int a,c,t;  
  float amount,value,temp;  
  FILE *fp;  
   clrscr();  
   printf("\n Welcome once again to Aarthi Banking Corporation (ABC)... ");  
   printf("\n\n Please Enter your Account Number");  
   scanf("%d",&num);  
   fp=fopen("customer.dat","r+");  
   rewind(fp);  
   while(!feof(fp)&&count==0)  
  { fread(&b,sizeof(b),1,fp);  
   if (b.accno==num)  
   {  count=1;  }   }  
   if(count==0)  
   {     printf("\n Wrong account number... No such user");  
   getch();  
   goto b;  }  
  else  
   { int m;  
   clrscr();  
   printf("\n Welcome %s, What service would you like to avail",b.name);  
   printf("\n 1. Deposit Amount ");  
   printf("\n 2. Withdraw Amount ");  
   printf("\n 3. View Details ");  
   printf("\n 4. Foreign Exchange");  
   printf("\n 5. Exit program");  
   printf("\n Please Enter your choice : ");  
   scanf ("%d",&m);  
   switch(m)  
   {case 1:  
   {clrscr();  
    printf("\n\n\n Dear %s, please enter the amount you wish to deposit : ",b.name);  
    scanf("%f",& amount);  
    b.bal=b.bal+amount;  
    printf("\n Your current available bank balance is %f", b.bal);  
    n=sizeof(b);  
    fseek(fp,-n,SEEK_CUR);  
    fwrite(&b,n,1,fp);  
    fclose(fp);  
    getch();  
    }break;  
    case 2:  
   {clrscr();  
    printf("\n\n\n Dear %s, please enter the amount you wish to withdraw : ",b.name);  
    scanf("%f",& amount);  
    if(b.bal-amount<=0)  
    {printf("\n Sorry, You dont have enough money in your account");  
    fclose(fp);  
    getch();  
    goto b;  
    }  
    else  
    {b.bal=b.bal-amount;  
    printf("\n Your current available bank balance is %f", b.bal);  
    getch();  
    n=sizeof(b);  
    fseek(fp,-n,SEEK_CUR);  
    fwrite(&b,n,1,fp);  
    fclose(fp);  
    goto b;  
    }  
    }break;  
    case 3:  
    { clrscr();  
    printf("\n Your Account Details are as folows...");  
    printf("\n\n Name : %s",b.name);  
    printf("\n\n Account Number : %d ",b.accno);  
    printf("\n\n Available Balance :%f ",b.bal);  
    fclose(fp);  
    printf("\n Press any key to continue...");  
    getch();   clrscr();  
    goto b;  
    }break;  
    case 4:  
    {int x;  
    float y,z;  
    clrscr();  
    printf("\n Welcome to the foreign exchange convertor section \n Select the currency you wish to convert.");  
    printf("\n 1. US Dollar");  
    printf("\n 2. Euro");  
    printf("\n 3. Pound");  
    scanf("%d",&x);  
    switch(x)  
    {  
    case 1:  
    {   printf("\n Please enter the amount of rupees you wish to convert");  
    scanf("%f",&y);  
    z=45/y;  
    printf("\n The converted rate is $ %f",z);  
    getch();  
    goto b;  
    }break;  
    case 2:  
    {   printf("\n Please enter the amount of rupees you wish to convert");  
    scanf("%f",&y);  
    z=75/y;  
    printf("\n The converted rate is euro %f",z);  
    getch();  
    goto b;  
    }break;  
    case 3:  
    {printf("\n Please enter the amount of rupees you wish to convert");  
    scanf("%f",&y);  
    z=60/y;  
    printf("\n The converted rate is pound %f",z);  
    getch();  
    goto b;  
    }break;  
    default:  
    exit(0);  
   }  }break;}}}}}

 

Other Projects to Try:

  1. How to Implement Hash Table using C language
  2. Sparse Matrix Operations Code using C Langauge
  3. Single Link List code using C Language
  4. Matrix operations in c language
  5. Banking Management System Project in Visual Basic with Source Code

Filed Under: C Assignments

Cricket Database Project

March 18, 2012 by ProjectsGeek Leave a Comment

 Cricket Database in C++

 

 #include  
 #include  
 #include  
 #include  
 #include  
 #include  
 #include  
 #include  
 #include  
 /*------------------base class--------------------------------------*/  
 class player  
 {  
   float strate,btavg,blavg;  
   int runs,wic,hiscr,bbol,overs,balls,innings,r1,w1,o1,b1,hcen,cen,i1;  
   public:  
   int mat;  
   char name[10];  
   char country[10];  
   player();  
   void getdata();  
   void update();  
   void showdata();  
   void calculation();  
   void search();  
   void modify();  
   void updatetest();  
   void menu();  
 };  
 /*----------------------constructor-------------------------------------*/  
 player::player()  
 {  
   strcpy(name," ");  
   strcpy(country," ");  
   strate=0;  
   btavg=0;  
   innings=0;  
   balls=0;  
   overs=0;  
   blavg=0;  
   runs=0;  
   wic=0;  
   mat=0;  
   hiscr=0;  
   bbol=0;  
   cen=0;  
   hcen=0;  
 }  
 /* -----------------------------fun for calculation ----------------------------*/  
 void player::calculation()  
 {  
   strate=(float)(runs/balls)*100;  
   btavg=(float)runs/innings;  
   blavg=(float)overs/wic;  
 }  
 /*---------------------- scan data from user ----------------------------------*/  
 void player::getdata()  
 {  
   cleardevice();  
   settextstyle(1,0,1);  
   outtextxy(100,50," ENTER DATA ");  
   settextstyle(0,0,1);  
   //cout<<"\n\t\t ENTER INFORMATION: \n\n";  
   cout<<"\n\n\n\t\t Name: ";  
   gets(name);  
   cout<<"\n\t\t Country: ";  
   gets(country);  
   cout<<"\n\t\t Matches: ";  
   cin>>mat;  
   cout<<"\n\t\t Innings: ";  
   cin>>innings;  
   cout<<"\n\t\t Runs: ";  
   cin>>runs;  
   cout<<"\n\t\t Balls Played: ";  
   cin>>balls;  
   cout<<"\n\t\t Fifties: ";  
   cin>>hcen;  
   cout<<"\n\t\t Hundreds: ";  
   cin>>cen;  
   cout<<"\n\t\t Overs Bowled: ";  
   cin>>overs;  
   cout<<"\n\t\t Wickets: ";  
   cin>>wic;  
   cout<<"\n\t\t Best Batting Performance: ";  
   cin>>hiscr;  
   cout<<"\n\t\t Best Bowling Performance: ";  
   cin>>bbol;  
 }  
 /*------------------------------ fun used for modification -------------------------*/  
 void player::update()  
 {  
   //cout<<"\n\n\t\t ENTER DATA OF LAST MATCH\n";  
   cleardevice();  
   settextstyle(1,0,1);  
   outtextxy(100,50," ENTER DATA OF LAST MATCH");  
   settextstyle(0,0,1);  
   cout<<"\n\n\n\t\t Runs: ";  
   cin>>r1;  
   if(r1>100)  
     cen++;  
   if(r1>50&&r1<100)  
     hcen++;  
   runs+=r1;  
   cout<<"\n\t\t Wickets: ";  
   cin>>w1;  
   wic+=w1;  
   mat++;  
   cout<<"\n\t\t OUT/NOTOUT(y/n): ";  
   char ch=getche();  
   if(ch=='y')  
     innings++;  
   cout<<"\n\t\t Overs Bowled :";  
   cin>>o1;  
   overs+=o1;  
   cout<<"\n\t\t Balls Played";  
   cin>>b1;  
   balls+=b1;  
   if(hiscr<r1) <br="">     hiscr=r1;  
   if(bbol<w1) <br="">     bbol=w1;  
 }  
 /*------------------------------------- fun for displaying the data ---------------------*/  
 void player::showdata()  
 {  
   int x=50;  
   char str[20];  
   cleardevice();  
   rectangle(50,150,610,250);  
   line(50,200,610,200);  
   for(int i=0;i<6;i++)  
   {  
     x+=80;  
     line(x,150,x,250);  
   }  
   outtextxy( 60,170,"MATCHS");  
   outtextxy(140,170,"RUNS");  
   outtextxy(220,170,"WICKETS");  
   outtextxy(300,170,"AVG(BAT)");  
   outtextxy(380,170,"AVG(BOL)");  
   outtextxy(460,170,"100`s");  
   outtextxy(540,170,"50`s");  
   outtextxy( 50,280,"BEST PERFORMANCE IN A MATCH ::");  
   outtextxy( 50,300,"RUNS : ");  
   outtextxy( 50,320,"WICKETS :");  
   sprintf(str,"%d",mat);  
   outtextxy(60,220,str);  
   sprintf(str,"%d",runs);  
   outtextxy(140,220,str);  
   sprintf(str,"%d",wic);  
   outtextxy(220,220,str);  
   sprintf(str,"%f",btavg);  
   outtextxy(300,220,str);  
   sprintf(str,"%f",blavg);  
   outtextxy(380,220,str);  
   sprintf(str,"%d",cen);  
   outtextxy(460,220,str);  
   sprintf(str,"%d",hcen);  
   outtextxy(540,220,str);  
   settextstyle(1,0,1);  
   sprintf(str,"%s",country);  
   outtextxy(50,110,str);  
   sprintf(str,"%s",name);  
   outtextxy(50,90,str);  
   settextstyle(0,0,1);  
   sprintf(str,"%d",hiscr);  
   outtextxy(130,300,str);  
   sprintf(str,"%d",bbol);  
   outtextxy(130,320,str);  
   getch();  
 }  
 fstream file,file1,tfile,tfile1;  
 int ch1;  
 /*----------------------------- main ----------------------------------------*/  
 void main()  
 {  
   player p;  
   clrscr();  
   int ch,i=0,gm,gd=DETECT;  
   char st[10];  
   int x,y;  
   x=100;  
   y=100;  
   initgraph(&gd,&gm,"g:\\tc\\bgi");  
   char pname[10],cname[10],password[10]="",c;  
   setbkcolor(BLUE);  
   while(!kbhit())  
   {  
     settextstyle(1,0,6);  
     outtextxy(150,200,"CRICKETER`S");  
     outtextxy(170,270,"DATABASE");  
   }  
   settextstyle(0,0,1);  
   cleardevice();  
   setcolor(11);  
   settextstyle(1,0,1);  
   outtextxy(100,380,"LOADING...");  
   for(i=0;i<401;i++)  
   {  
     outtextxy(100+i,400,"#");  
     if(i<400&&i>370)  
     delay(40);  
    delay(10);  
   }  
   settextstyle(0,0,1);  
   cleardevice();  
   getch();  
   //cleardevice();  
   /*------------------ starting menu ------------------*/  
   int tag;  
   tag:  
   cleardevice();  
   settextstyle(1,0,2);  
   outtextxy(200,100," 1 :: ONE DAY") ;  
   outtextxy(200,130,"   2 :: TEST") ;  
   //cin>>ch1;  
   ch1=getche();  
   ch1=ch1-'0';  
   settextstyle(0,0,1);  
   if(ch1==1)  
   {  
     do  
     {  
       cleardevice();  
       //p.menu();  
       settextstyle(1,0,2);  
       outtextxy(200,100," 1 :: ADD RECORDS ") ;  
       outtextxy(200,130," 2 :: MODIFY RECORDS ") ;  
       outtextxy(200,160," 3 :: SEARCH RECORD (NAME)") ;  
       outtextxy(200,190," 4 :: SEARCH RECORD (COUNTRY)") ;  
       outtextxy(200,220," 5 :: LIST OF PLAYER OF ONE COUNTRY") ;  
       outtextxy(200,250," 6 :: BACK") ;  
       outtextxy(200,280," 7 :: EXIT") ;  
       //cin>>ch;  
       ch=getche();  
       ch=ch-'0';  
       settextstyle(0,0,1);  
       switch(ch)  
       {  
         /*----- ODI insert ----------------------*/  
         case 1:  
         cleardevice();  
         file.open("ODI.txt",ios::in|ios::out|ios::ate);  
         file.seekp(0,ios::end);  
         p.getdata();  
         p.calculation();  
         file.write((char*)&p,sizeof(p));  
         file.clear();  
         file.close();  
         c=getch();  
         break;  
         /*------- ODI name wise search --------------------*/  
         case 3:  
         cleardevice();  
         cout<<"\n\t\t Name For Search: ";  
         gets(pname);  
         cleardevice();  
         setcolor(10);  
         outtextxy(100,380,"LOADING...");  
         for(i=0;i<401;i++)  
         {  
           outtextxy(100+i,400,"#");  
           //if(i>250&&i<300)  
            //  delay(40);  
           delay(10);  
         }  
         cleardevice();  
         int flag=0;  
         file.open("ODI.txt",ios::in|ios::out|ios::ate);  
         file.seekp(0,ios::beg);  
         while(file.read((char*)&p,sizeof(p)))  
         {  
           if(!strcmp(p.name,pname))  
           {  
             flag=1;  
             cout<<"\n\n";  
             p.showdata();  
             break;  
           }  
         }  
         file.clear();  
         file.close();  
         if(flag==0)  
         cout<<"\n\t\t Record Not Found";  
         //cout<<"\n\n\t\t Enter Any Key To Cont.";  
         //cin>>c;  
         c=getch();  
         break;  
         /*-------------- ODI modification -------------------------*/  
         case 2:  
         cleardevice();  
         cout<<"\n\t\tENTER PASSWORD ";  
         int i=0;  
         while(i<6)  
         {  
            password[i]=getche();  
         cout<<"*";  
         i++;  
         }  
         getch();  
         cleardevice();  
         setcolor(10);  
         outtextxy(100,380,"LOADING...");  
         for(i=0;i<401;i++)  
         {  
           outtextxy(100+i,400,"#");  
           delay(10);  
           if(i>350&&i<400)  
             delay(40);  
         }  
         cleardevice();  
         if(!strcmp("vineet",password))  
         {  
           cout<<"\n\t\t Name For Modification ";  
           gets(pname);  
           flag=0;  
           file.open("ODI.txt",ios::in|ios::out|ios::ate);  
           file1.open("temp1.txt",ios::in|ios::out|ios::ate);  
           if(!tfile1)  
             cout<<"\nerror";  
           file1.seekp(0,ios::beg);  
           file.seekp(0,ios::beg);  
           while(file.read((char*)&p,sizeof(p)))  
           {  
             if(!strcmp(p.name,pname))  
             {  
               flag=1;  
               p.update();  
               p.calculation();  
               file1.write((char*)&p,sizeof(p));  
             }  
             else  
             {  
               tfile1.write((char*)&p,sizeof(p));  
             }  
           }  
           file.clear();  
           file.close();  
           file1.clear();  
           file1.close();  
           if(flag==1)  
           {  
             remove("ODI.txt");  
             rename("temp1.txt","ODI.txt");  
           }  
           if(flag==0)  
             cout<<"\n\t\t Record Not Found";  
         }  
         else  
           cout<<"\n\t\t Wrong Password";  
         c=getch();  
         break;  
         /*------------ ODI country wise search --------------*/  
         case 4:  
         cleardevice();  
         cout<<"\n\t\t Country`s Name For Search: ";  
         gets(cname);  
         cleardevice();  
         setcolor(10);  
         outtextxy(100,380,"LOADING...");  
         for(i=0;i<401;i++)  
         {  
           outtextxy(100+i,400,"#");  
           delay(10);  
           //if(i>333&&i<400)  
            //  delay(40);  
         }  
         cleardevice();  
         flag=0;  
         file.open("ODI.txt",ios::in|ios::out|ios::ate);  
         file.seekp(0,ios::beg);  
         while(file.read((char*)&p,sizeof(p)))  
         {  
           if(!strcmp(p.country,cname))  
           {  
             flag=1;  
             cout<<"\n\n";  
             p.showdata();  
           }  
         }  
         file.clear();  
         file.close();  
         if(flag==0)  
           cout<<"\n\t\t Record Not Found";  
         //cout<<"\n\n\t\t Enter Any Key To Cont.";  
         //cin>>c;  
         c=getch();  
         break;  
         /*------ ODI list of players ---------------------*/  
         case 5:  
         cleardevice();  
         cout<<"\n\t\t Country`s Name For Search: ";  
         gets(cname);  
         cleardevice();  
         setcolor(10);  
         outtextxy(100,380,"LOADING...");  
         for(i=0;i<401;i++)  
         {  
           outtextxy(100+i,400,"#");  
           delay(10);  
         }  
         cleardevice();  
         flag=0;  
         file.open("ODI.txt",ios::in|ios::out|ios::ate);  
         file.seekp(0,ios::beg);  
         while(file.read((char*)&p,sizeof(p)))  
         {  
           if(!strcmp(p.country,cname))  
           {  
             flag=1;  
             settextstyle(1,0,1);  
             //cout<<"\n\n\t\t"<<p.name; <br="">

             sprintf(st,"%s",p.name);  
             outtextxy(x,y,st);  
             y=y+30;  
             settextstyle(0,0,1);  
           }  
         }  
         file.clear();  
         file.close();  
         if(flag==0)  
         cout<<"\n\t\t Record Not Found";  
         //cout<<"\n\n\t\t Enter Any Key To Cont.";  
         //cin>>c;  
         c=getch();  
         break;  
         case 6:  
         goto tag;  
         //break;  
         case 7:  
         exit(0);  
         break;  
       }  
     }while(1);  
   }  
   if(ch1==2)  
   {  
     do  
     {  
       cleardevice();  
       //p.menu();  
       settextstyle(1,0,2);  
       outtextxy(200,100," 1 :: ADD RECORDS ") ;  
       outtextxy(200,130," 2 :: MODIFY RECORDS ") ;  
       outtextxy(200,160," 3 :: SEARCH RECORD (NAME)") ;  
       outtextxy(200,190," 4 :: SEARCH RECORD (COUNTRY)") ;  
       outtextxy(200,220," 5 :: LIST OF PLAYER OF ONE COUNTRY") ;  
       outtextxy(200,250," 6 :: BACK") ;  
       outtextxy(200,280," 7 :: EXIT") ;  
       //cin>>ch;  
       ch=getche();  
       ch=ch-'0';  
       settextstyle(0,0,1);  
       switch(ch)  
       {  
         /*------------------ TEST insert ------------------*/  
         case 1:  
         cleardevice();  
         tfile.open("TEST.txt",ios::in|ios::out|ios::ate);  
         tfile.seekp(0,ios::end);  
         p.getdata();  
         p.calculation();  
         tfile.write((char*)&p,sizeof(p));  
         tfile.clear();  
         tfile.close();  
         break;  
         /*------------------ TEST name wise search ------------------*/  
         case 3:  
         cleardevice();  
         cout<<"\n\t\t Name For Search: ";  
         gets(pname);  
         cleardevice();  
         setcolor(10);  
         outtextxy(100,380,"LOADING...");  
         for(i=0;i<401;i++)  
         {  
           outtextxy(100+i,400,"#");  
           delay(10);  
           if(i>350&&i<400)  
             delay(40);  
         }  
         cleardevice();  
         int flag=0;  
         tfile.open("TEST.txt",ios::in|ios::out|ios::ate);  
         tfile.seekp(0,ios::beg);  
         while(tfile.read((char*)&p,sizeof(p)))  
         {  
           if(!strcmp(p.name,pname))  
           {  
             flag=1;  
             cout<<"\n\n";  
             p.showdata();  
             break;  
           }  
         }  
         tfile.clear();  
         tfile.close();  
         if(flag==0)  
         cout<<"\n\t\t Record Not Found";  
         c=getch();  
         break;  
         /*------------------ TEST modification ------------------*/  
         case 2:  
         cleardevice();  
         cout<<"\n\t\tENTER PASSWORD";  
         int i=0;  
         while(i<6)  
         {  
            password[i]=getche();  
         cout<<"*";  
         i++;  
         }  
         getch();  
         cleardevice();  
         setcolor(10);  
         outtextxy(100,380,"LOADING...");  
         for(i=0;i<401;i++)  
         {  
           outtextxy(100+i,400,"#");  
           delay(10);  
           if(i>350&&i<400)  
             delay(40);  
         }  
         cleardevice();  
         if(!strcmp("vineet",password))  
         {  
           cout<<"\n\t\t Name For Modification ";  
           gets(pname);  
           flag=0;  
           tfile.open("TEST.txt",ios::in|ios::out|ios::ate);  
           tfile1.open("temp1.txt",ios::in|ios::out|ios::ate);  
           if(!tfile1)  
             cout<<"\nerror";  
           tfile1.seekp(0,ios::beg);  
           tfile.seekp(0,ios::beg);  
           while(tfile.read((char*)&p,sizeof(p)))  
           {  
             if(!strcmp(p.name,pname))  
             {  
               flag=1;  
               cout<<"\n\t\t Enter Data For First Inning: ";  
               p.update();  
               cout<<"\n\t\t Enter Data For Second Inning: ";  
               p.update();  
               p.mat--;  
               p.calculation();  
               tfile1.write((char*)&p,sizeof(p));  
             }  
             else  
             {  
               tfile1.write((char*)&p,sizeof(p));  
             }  
           }  
           tfile.clear();  
           tfile.close();  
           tfile1.clear();  
           tfile1.close();  
           if(flag==1)  
           {  
             remove("TEST.txt");  
             rename("temp1.txt","TEST.txt");  
           }  
           if(flag==0)  
             cout<<"\n\t\t Record Not Found";  
         }  
         else  
           cout<<"\n\t\t Wrong Password";  
         c=getch();  
         break;  
         /*------------------ TEST country wise search ------------------*/  
         case 4:  
         cleardevice();  
         cout<<"\n\t\t Country`s Name For Search: ";  
         gets(cname);  
         cleardevice();  
         setcolor(10);  
         outtextxy(100,380,"LOADING...");  
         for(i=0;i<401;i++)  
         {  
           outtextxy(100+i,400,"#");  
           delay(10);  
           if(i>350&&i<400)  
             delay(40);  
         }  
         cleardevice();  
         flag=0;  
         tfile.open("TEST.txt",ios::in|ios::out|ios::ate);  
         tfile.seekp(0,ios::beg);  
         while(tfile.read((char*)&p,sizeof(p)))  
         {  
           if(!strcmp(p.country,cname))  
           {  
             flag=1;  
             cout<<"\n\n";  
             p.showdata();  
           }  
         }  
         tfile.clear();  
         tfile.close();  
         if(flag==0)  
         cout<<"\n\t\t Record Not Found";  
         break;  
         /*------------------ TEST list ------------------*/  
         case 5:  
         cleardevice();  
         cout<<"\n\t\t Country`s Name For Search: ";  
         gets(cname);  
         cleardevice();  
         setcolor(10);  
         outtextxy(100,380,"LOADING...");  
         for(i=0;i<401;i++)  
         {  
           outtextxy(100+i,400,"#");  
           delay(10);  
           if(i>350&&i<400)  
             delay(40);  
         }  
         cleardevice();  
         flag=0;  
         tfile.open("TEST.txt",ios::in|ios::out|ios::ate);  
         tfile.seekp(0,ios::beg);  
         while(tfile.read((char*)&p,sizeof(p)))  
         {  
           if(!strcmp(p.country,cname))  
           {  
             flag=1;  
             settextstyle(1,0,1);  
             //cout<<"\n\n\t\t"<<p.name; <br="">

             sprintf(st,"%s",p.name);  
             outtextxy(x,y,st);  
             y=y+30;  
             settextstyle(0,0,1);  
             //cout<<"\n\n\t\t"<<p.name; <br="">

           }  
         }  
         file.clear();  
         file.close();  
         if(flag==0)  
         cout<<"\n\t\t Record Not Found";  
         //char c;  
         //cout<<"\n\n\t\t Enter Any Key To Cont.";  
         //cin>>c;  
         c=getch();  
         break;  
         case 6:  
         goto tag;  
         case 7:  
         exit(0);  
         break;  
       }  
     }while(1);  
   }  
 }  
 /* ------------------------------end of main -------------------------------*/

 
 

Other Projects to Try:

  1. string operations such as Copy, Length, Reversing, Palindrome, Concatenation
  2. Expression Tree using C Language
  3. Graphics Editor code Using C++ Language
  4. Cricket Database project using C++
  5. Cricket Game Java Project

Filed Under: C Assignments

Exception Handling in C++ Language

April 6, 2011 by ProjectsGeek Leave a Comment

Exception Handling in C++ Language

Create a class named Television that has data members to hold the model number and the screen size in inches,and the price for Exception Handling in C++ program.Member functions include overloaded insertion and extraction operators.If more than four digits are entered for the model,if the screen size is smaller than 12 or greater than 70 inches, or if the price is negative or over $5000 then throw an integer.

Write a main() function that instantiates a television object,allows user to enter data and displays the data members .If an exception is caught ,replace all the data member values with zero values .

Exception Handling in C++ Code

#include  
 #include  
 void test(int,int,int);  
 class television  
 {  
   public:  
   int mod_no,price,size;  
   void operator<<(telivision a)  
   {  
     cout<<"\n\t## INPUT ##";  
     cout<<"\n\tENTER THE MODEL NO.:";  
     cin>>mod_no;  
     cout<<"\n\tENTER THE SIZE:";  
     cin>>size;  
     cout<<"\n\tENTER THE PRICE:";  
     cin>>price;  
     test(mod_no,price,size);  
     getch();  
   }  
   void operator>>(television a)  
   {  
     cout<<"\n\t## DISPLAY ##)";  
     cout<<"\nMODEL NO.:"<<mod_no<<"\nsize:"<<size<<"\nprice:"<<price; <br="">     getch();  
   }  
 };  
 void test(int mod_no,int price,int size)  
 {  
   if(mod_no>=10000)  
     throw(1);  
   if(price>5000)  
     throw(2);  
   if(price<0)  
     throw(3);  
   if(size<12)  
     throw(4);  
   if(size>70)  
     throw(5);  
 }  
 void main()  
 {  
   int ch,i;  
   television n,o;  
   do  
   {  
     cout<<"\n\t##### MAIN MENU #####";  
     cout<<"\n\t1.INPUT";  
     cout<<"\n\t2.DISPLAY";  
     cout<<"\n\t3.EXIT";  
     cout<<"\n\tENTER UR CHOICE:";  
     cin>>ch;  
     switch(ch)  
     {  
       case 1:  
         try  
         {  
           n<<o; <br="">         }  
         catch(int i)  
         {  
           if(i==1)  
             cout<<"\nMODEL NO IS NOT CORRECT";  
           else if(i==2)  
             cout<<"\nPRICE IS NOT CORRECT";  
           else if(i==3)  
             cout<<"\nPRICE IS NEGATIVE";  
           else if(i==4)  
             cout<<"\nSIZE IS VERY SMALL";  
           else if(i==5)  
             cout<<"\nSIZE IS VERY LARGE";  
           n.mod_no=0;  
           n.price=0;  
           n.size=0;  
         }  
         getch();  
         break;  
       case 2: n>>o;  
         getch();  
         break;  
       case 3: break;  
     }  
   }while(ch!=3);  
 }

 

Other Projects to Try:

  1. How to Implement Hash Table using C language
  2. Hash table code in C Language
  3. Exception Handling In java
  4. File Handling and IO Handling in Java Programming
  5. Matrix Operations in C Language

Filed Under: C Assignments, Computer Graphics Tagged With: Computer Graphics

Student Database using Virtual functions in C++

April 6, 2011 by ProjectsGeek 1 Comment

Student Database using Virtual functions in C++

Design a base class consisting of the data members such as name of the student,roll number and subject.The derived class consists of the data members subject code,internal assessment and university examination marks.Construct a virtual base class for the item name of the student and roll number.The program should have the facilities.

  • Build a master table
  • List a table
  • Insert a new entry
  • Delete old entry
  • Edit an entry
  •  Search for a record

Student Database using Virtual functions in C++Code

 #include  
 #include  
 #include  
 #include  
 class assessment;  
 class student  
 {  
   char name[20],sub[20];  
   int rno,sub_code,in,uni;  
   public:  
   friend assessment;  
 };  
 class assessment  
 {  
   int internal,uni_marks;  
   public:  
   void menu();  
   void input(student *S);  
   void display(student *S);  
   int rlno(student *S);  
   void del(student *S);  
   void modify(student *S);  
 };  
 void assessment::input(student *S)  
 {  
   cout<<"\nEnter name : ";  
   gets(S->name);  
   cout<<"\nEnter Roll no : ";  
   cin>>S->rno;  
   cout<<"\nEnter subject : ";  
   gets(S->sub);  
   cout<<"\nEnter sub code : ";  
   cin>>S->sub_code;  
   cout<<"\nEnter Internal marks : ";  
   cin>>internal;  
   S->in=internal;  
   cout<<"\nEnter University exam marks : ";  
   cin>>uni_marks;  
   S->uni=uni_marks;  
 }  
 void assessment::display(student *S)  
 {  
   cout<<"\n"<rno;  
   cout<<"\t"<name;  
   cout<<"\t"<sub;  
   cout<<"\t"<sub_code;  
   cout<<"\t"<in;  
   cout<<"\t"<uni;  
 }  
 void assessment::menu()  
 {  
   cout<<"\t\t\t"<<"STUDENT DATABASE MANAGENENT"<<endl<<"\n1.create"<<endl; <br="">   cout<<"2.Display"<<endl<<"3.insert"<<endl; <br="">   cout<<"4.Delete"<<endl<<"5.modify"; <br="">   cout<<endl<<"6.search"<<endl<<"7.exit"; <br=""> }  
 int assessment::rlno(student *S)  
 {  
   return (S->rno);  
 }  
 void assessment ::modify(student *S)  
 {  
   int ch;  
   do  
   {  
     clrscr();  
     cout<<"EDIT"<<endl<<"1.roll no"<<endl<<"2.name";="" <br="">     cout<<endl<<"3.subject"<<endl<<"4.sub code"<<endl<<"5.int="" assesment";="" <br="">     cout<<endl<<"6.uni exam"<<endl<<"7.exit";="" <br="">     cin>>ch;  
     switch(ch)  
     {  
       case 1:  
          cout<<endl<<"new roll="" no="" :="" ";="" <br="">          cin>>S->rno;  
          break;  
       case 2:  
          cout<<endl<<"new name="" :="" ";="" <br="">          gets(S->name);  
          break;  
       case 3:  
          cout<<endl<<"new subject="" :="" ";="" <br="">          cin>>S->sub;  
          break;  
       case 4:  
          cout<<endl<<"new code="" :="" ";="" <br="">          cin>>S->sub_code;  
          break;  
       case 5:  
          cout<<endl<<"new int="" assessment="" :="" ";="" <br="">          cin>>internal;  
          break;  
       case 6:  
          cout<<endl<<"new university="" marks="" :="" ";="" <br="">          cin>>uni_marks;  
          break;  
       case 7:  
          break;  
       default:  
           cout<<"Invalid Choice";  
     }  
   }while(ch!=7);  
 }  
 void main()  
 {  
   fstream inoutf;  
   ifstream inf;  
   student S;  
   assessment A;  
   int ch,flag=0,ct=0;  
   int r;  
   char c;  
   do  
   {  
     clrscr();  
     flag=0;  
     A.menu();  
     cout<<"\n\nEnter your choice : ";  
     cin>>ch;  
     clrscr();  
     switch(ch)  
     {  
       case 1:  
          inoutf.open("student.txt",ios::out|ios::binary);  
          do  
          {  
           A.input(&S);  
           inoutf.write((char*) &S,sizeof(S));  
           cout<<"Want to enter again y/n";  
           cin>>c;  
          }while(c=='y');  
          inoutf.close();  
          break;  
       case 2:  
          inf.open("student.txt",ios::in|ios::binary );  
          inf.seekg(0);  
          cout<<"\nRNo\tName\tSub\tCode\tAsmnt\tMarks";  
          //while(!inf.eof())  
          while(inf.read((char*)&S,sizeof(S)))  
          {  
           A.display(&S);  
          }  
          inf.close();  
          break;  
       case 3:  
          inoutf.open("student.txt",ios::out|ios::binary|ios::app);  
          inoutf.clear();  
          A.input(&S);  
          inoutf.write((char*)&S,sizeof(S));  
          inoutf.close();  
          break;  
       case 4:  
          cout<<"Enter Roll no to be deleted : ";  
          cin>>r;  
          inf.open("student.txt",ios::in|ios:: binary);  
          inoutf.open("temp.txt",ios::in|ios::out|ios::binary|ios::app);  
          inf.seekg(0);  
          while(inf.read((char*) & S,sizeof(S)))  
          {  
           if(r==A.rlno(&S))  
           {  
             flag=1;  
             //break;  
           }  
           else  
           {  
             inoutf.write((char*)&S,sizeof(S));  
           }  
          }  
          if(flag!=1)  
           cout<<"\n\nRoll no not found";  
          else  
           cout<<"\n\nDeleted";  
          inf.close();  
          inoutf.close();  
          remove("student.txt");  
          rename("temp.txt","student.txt");  
          break;  
       case 5:  
          ct=0;  
          cout<<"Enter Roll no to be modified : ";  
          cin>>r;  
          inoutf.open("student.txt",ios::in|ios:: binary|ios::out);  
          inoutf.seekg(0);  
          while(inoutf.read((char*) & S,sizeof(S)))  
          {  
           if(r==A.rlno(&S))  
           {  
             flag=1;  
             break;  
           }  
           ct++;  
          }  
          if(flag!=1)  
           cout<<"\n\nRoll no not found";  
          else  
          {  
           ct=ct*sizeof(S);  
           inoutf.seekg(ct,ios::beg);  
           A.modify(&S);  
           inoutf.write((char*)&S,sizeof(S));  
          }  
          inoutf.close();  
          break;  
       case 6:  
          inf.open("student.txt",ios::in |ios::binary );  
          inf.seekg(0);  
          cout<<"Enter Roll no to be searched : ";  
          cin>>r;  
          //while(!inf.eof())  
          while(inf.read((char*)&S,sizeof(S)))  
          {  
           if(r==A.rlno(&S))  
           {  
             flag=1;  
             break;  
           }  
           else  
             flag=0;  
          }  
          if(flag==1)  
          {  
           cout<<"\n\nRecord found";  
           cout<<"\nRNo\tName\tSub\tCode\tAsmnt\tMarks";  
           A.display(&S);  
          }  
          else  
           cout<<"\nRecord not found";  
          inf.close();  
       case 7:  
          break;  
       default:  
           cout<<"Invalid dirn";  
     }  
     getch();  
   }while(ch!=7);  
  inoutf.close();  
 }

 

Other Projects to Try:

  1. Cricket Database Project
  2. Cricket Database project using C++
  3. Friend Function Implementation using C++
  4. Student Database in C Language
  5. Operator Overloading on String Functions C++ Language

Filed Under: C Assignments, Computer Graphics Tagged With: Computer Graphics

  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • Go to Next Page »

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy