Monday, 20 October 2014

Program Of Get Manipulator In C++

#include<iostream.h>
#include<conio.h>
 main()
 {
 clrscr();
 const int max=40;
 char str[max];
 cout<<"\n enter string=";
 cout<<"string is="<<str;
 getch();
 }

Friday, 2 November 2012

Program Of And, comma(,) , Relational(>) Operator In C++


#include<iostream.h>
#include<conio.h>

{

clrscr();

int a,b,c;

cout<<"Enter a,b,c";

cin>>a>>b>>c;


{
cout<<"\n a is Greater";

}


{
cout<<"\n b is Greater";

}


{
cout<<"\n c is Greater";

}


getch();
}

Wednesday, 31 October 2012

Program Of Increament and Decreament, Uniary Operator In C++


#include<iostream.h>
#include<conio.h>

main()

{

clrscr();

int a,b,c,d,e,f;


a=10;

                           b=++a;         //a=11 , b=11
                           c=a--;           //c=11 , a=10
                       d=--a;           //a=9 , d=9 
                       e=--a;           //e=8 , a=8
                       f=a++;         // a=8 , f=9
        
cout<<"\n a="<<a;
        
cout<<"\n b="<<b;
       
 cout<<"\n c="<<c;
       
       
      
  
 getch();
}

Program Of Unary Operator Overloading In C++

#include<iostream.h>
#include<conio.h>
 
{
 
    private:
 
    int a;
 
    public:
  
  void getdata(int x)
 
    {
 
      a= x;   
 
    }
  
    {
 
    a++;
 
    }
 
    void display()
 
    {
     
 cout<<"\n a="<<a;   
 
    }
 
}
 
main()
 
{
 
clrscr();
 
box b1;
 
int x;
 
cout<<"Enter x=";
 
cin>>x;
 
++b1;
 
++b1;
 
++b1;
 
++b1;
 
getch();
 
}

Monday, 29 October 2012

Program Of Reverse String In C++

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
 
main()
 
{
 
clrscr();
 
char x[20];
 
int l;
 
//cout<<"Enter String=";
 
//cin>>x;
 
gets(x);
 
reverse(x);
 
getch();
 
}
 
{
 
int p=0,i;
 
for(i=0;a[i]!='\0';i++)
 
{
 
p++;
 
}
 
{
 
cout<<a[i];
 
}
 
}

Program Of Sub String In C++

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
 
main()
 
 {
 
clrscr(); 
char x[20];
 
int l; 
puts("Enter string=");
 
gets(x);
 
getch();
 
}
 
void substr(char a[20]) 

{
 
int beg,end,i;
 
cout<<"Enter Beging & Ending Number=";
 
cin>>beg>>end;
 
{
 
cout<<a[i];
 
}
 
}

Program Of GET PUT Function In C

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
 
main()
 
{
 
clrscr();
 
int i,a,m,n;
 
printf("Enter No. Of Char");
 
scanf("%d",&m);
 
printf("\n Contens Of Main File=");
 
for(i=1;i<=m;i++)
 
{
 
scanf("%d",&n);
 
if(n==-1)
 
break;
 
}
 
fclose(f1);
 
f1=fopen("Main","r");
 
f2=fopen("ODD","w");
 
f3=fopen("EVEN","w");
 
while(a!=EOF)
 
{
 
if(a%2==0)
 
{
 
}
 
else
 
{
putw(a,f2);
 
}
 
a=getw(f1);
 

fclose(f1);
 
fclose(f2);
 
fclose(f3);
 
f2=fopen("ODD","r");
 
f3=fopen("EVEN","r");
 
printf("Content of ODD File \n");
 

{
 
printf("%d\n",a);
 
}
 
printf("Content Of Even File\n ");
 
while(a=getw(f3)!=EOF)
 
{
 
printf("%d\n",a);
 
}
 
fclose(f2);
 
fclose(f3);
 
getch();
 
}

Saturday, 27 October 2012

Program Of Write Arguments From Memory In C


#include  <stdio.h>
#include <conio.h>
 
 int  argc;                   
 
   char *argv[];               
 
   {
   
    FILE   *fp;
      
 int  i;
     
  char word[15];

       
fp = fopen(argv[1], "w");
    
   printf("\nNo. of arguments in Command line = %d\n\n",argc);
    
   for(i = 2; i < argc; i++)
    
    fclose(fp);

    Writing Content Of The File To Screen 


       printf("Contents of %s file\n\n", argv[1]);
     
  fp = fopen(argv[1], "r");
       
for(i = 2; i < argc; i++)
 
       {
   
 printf("%s ", word);
       }

      
 fclose(fp);
      
 printf("\n\n");

     Writing the Arguments From Memory

       for(i = 0; i < argc; i++)
     
  getch();
   }

Reading Data From Command Line

 Reading Data From Command Line


#include  <stdio.h>
 
#include <conio.h>
 
                                     int  argc;            /*   argument count */
                        
                                   char *argv[];        /* list of arguments */
 
   {
      
 FILE   *fp;
  
     int  i;
      
 char word[15];
     
       fp = fopen(argv[1], "w"); /* open file with name argv[1] */
   
    printf("\nNo. of arguments in Command line = %d\n\n",argc);
 
       for(i = 2; i < argc; i++)
    
          fprintf(fp,"%s ", argv[i]);      /* write to file argv[1]  */
       
fclose(fp);

 
    getch();
   }

Program Of Append Records Using C

Coding Of Append Records Using c


#include<stdio.h>
 
#include<conio.h>
 
   {
    
   char   name[10];
   
    int    number;
  
     float  price;
   
    int    quantity;
 
   };
 
 void main()
 
   {
  
    char  filename[10];
    
   int   response; 

       FILE  *fp;
 
       long  n;
   
      printf("Type filename:");
 
      scanf("%s", filename);
    
   fp = fopen(filename, "a+");
 
       do
 
       {
 
      append(&item, fp);
    
  printf("\nItem %s appended.\n",item.name);
     
 printf("\nDo you want to add another item\        (1 for YES /0 for NO)?");
    
  scanf("%d", &response);
 
       } 
 while (response == 1);
    
       n=ftell(fp);
 
       fclose(fp);
    
   fp = fopen(filename, "r");
 
  while(ftell(fp) < n)
 
       {
    
  fscanf(fp,"%s %d %f %d",
      item.name, &item.number, &item.price, &item.quantity); 
     
 fprintf(stdout,"%-8s %7d %8.2f %8d\n",
    
  item.name, item.number, item.price, item.quantity);
 
       }
   
    fclose(fp);
 
  getch();
 
   }
 
 

Friday, 26 October 2012

Program Of Data Entry Or Add Records Using C

#include<stdio.h> 
#include<conio.h>
 
#include<string.h>
 
{
 

char name[40];
 

int age;
 

float bs;
 

};
 

main()
 

{
 

clrscr();
 

FILE *fp;
 
struct emp e;
 
char s[80];
 
char another='y';
 
if(fp==NULL)
 
{
 
printf("Can't Open File");
 
exit(1);
 
}
 
printf("\n File  TEXT Is=");
 
printf("\n");
 
printf("\n Enter Name,AGE,Basic salary");
 
scanf("%s",e.name);
 
scanf("%d",&e.age);
 
scanf("%f",&e.bs);
 
printf("Add Another Record(y/n)");
 
another=getche();
 
}
 
fclose(fp);
 
getch();
 
}

Thursday, 25 October 2012

Program Of Palindrom In C++


#include<iostream.h>
#include<conio.h>

main()

{

clrscr();

int a,b,c,d,e,f;

cout<<"enter number=";

cin>>a;

b=a/10;

c=a%10;

d=b/10;

e=b%10;


if(f==a)

 {

 cout<<"\n palindrom";

 }

else

 {

 cout<<"\n not palindrom";

 }

 getch();

 }

Program Of Swap Two Numbers With Class


#include<iostream.h>
#include<conio.h>

{

private:
int a,b;

public:

{

a=x;
b=y;

}
void display()

{
int c;

c=a;
a=b;


cout<<"\n first mumber="<<a;
cout<<"\n second number="<<b;

}
};

main()
{
clrscr();

int p,q;
cout<<" enter first mumber=";

cin>>p;
cout<<"enter second mumber=";

cin>>q;

s1.display();
getch();

}