C program for Macro Processor

Monday, March 29th, 2010  »  Posted By Ranjith  »  Total 1 Comment

C program for Macro Processor #include<stdio.h> #include<conio.h> #define getx1y1 printf("Enter the order of Ist Matrix:"); scanf("%d%d",&x1,&y1);   #define getx2y2 printf("Enter the order of IIst Matrix:"); scanf("%d%d",&x2,&y2);   #define inputa printf("Enter the value of a:"); for(i=0;i<x1;i++) for(j=0;j<y1;j++) scanf("%d",&a[i][j]);   #define inputb printf("Enter the value of b:"); for(i=0;i<x2;i++) for(j=0;j<y2;j++) scanf("%d",&b[i][j]);   #define addab for(i=0;i<x1;i++) { for(j=0;j<y1;j++) { [...]

C program for Lexical Analyzer

Monday, March 29th, 2010  »  Posted By Ranjith  »  Total 5 Comments

C program for Lexical Analyzer #include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> struct pgm { char line[20]; } s[100]; void check(char s[]) { cout<<"\n"; if(!strcmpi(s,"If")) { cout<<"keyword:If"; return; } if(!strcmpi(s,"Then")) { cout<<"keyword:Then"; return; } if(!strcmpi(s,"Else")) { cout<<"keyword:else"; return; } if(!strcmpi(s,"[END]")) { return; } cout<<"expression:"<<s; } void main() { char t[20]; int i=0,j=0,k=0; clrscr(); cout<<"\n\n enter the [...]

C progrma for First Come First Serve Algorithm

Monday, March 29th, 2010  »  Posted By Ranjith  »  Total 5 Comments

C progrma for First Come First Serve Algorithm #include<stdio.h> #include<math.h> #include<conio.h> void main() { clrscr(); int p[20],b[20],w[20],t[20],i,v,n,at; int wt=0; float tw,tr; printf("Enter the number of process : "); scanf("%d",&n); printf("enter CPU burst time : "); for(i=1;i<=n;i++) { scanf("%d",&b[i]); t[1]=b[1]; w[1]=0; at=t[1]; wt=w[1]; for(i=2;i<=n;i++) { t[i]=b[i]+t[i-1]; at=at+t[i]; w[i]=t[i-1]; wt=wt+w[i]; } } printf("process \t burst_time \t wait_time [...]

C++ program to copy one file to anothere file

Saturday, March 13th, 2010  »  Posted By Ranjith  »  Total 2 Comments

AIM A program to copy one file to another file and convert the lower case characters to upper case characters. ALGORITHM 1) Start the process 2) Create the input file and out put file. 3) Get the input file name to fname1. 4) Get the output file name to fname2. 5) Open the infile(fanme1) 6) [...]

C++ class program to illestrate File operations

Saturday, March 13th, 2010  »  Posted By Ranjith  »  Total 1 Comment

AIM Write a program to illustrate the write() member function which are usually used for transfer of data blocks to the file. ALGORITHM 1. Start the process 2. Invoke the class a. Create two inline member functions .ie, getdata() and dispdata() i. getdata() for input ii. dispdata() for display 3. Open the file in fstream [...]

C++ program to implement Pure Virtual Functions

Saturday, March 13th, 2010  »  Posted By Ranjith  »  Total 2 Comments

AIM A program to demonstrate how a pure virtual function is defined, declared and invoked from the object of derived class through the pointer of the base class. ALGORITHM 1. Start the process 2. Invoke the class with pointer 3. Assign ptrgetdata() a. Get the roll no and name of the student 5. Call the [...]

C++ program to illestrate virtual functions

Saturday, March 13th, 2010  »  Posted By Ranjith  »  Total 0 Comment

AIM A program to access the member of the derived class objects through an array of members. In this program, both the base class and the derived class member functions are preceded by the keyword ALGORITHM 1. Start the process 2. Invoke the class with pointer 3. Assign ptr[0]

C++ program to illustrate the static member function

Saturday, March 13th, 2010  »  Posted By Ranjith  »  Total 3 Comments

AIM Write a program to illustrate the static member function. ALGORITHM 1. Start the process 2. Invoke the class i. Set the data member and member function as a static b. Create two objects t1 and t2 3. Call the function t1.setcode i. Increment the value of data member count 4. Call the function t1.setcode [...]

C++ program to illustrate Hybrid Inheritance.

Saturday, March 13th, 2010  »  Posted By Ranjith  »  Total 3 Comments

C++ program to illustrate Hybrid Inheritance. #include<iostream.h> #include<conio.h> class stu { protected: int rno; public: void get_no(int a) { rno=a; } void put_no(void) { out<<"Roll no"<<rno<<"\n"; } }; class test:public stu { protected: float part1,part2; public: void get_mark(float x,float y) { part1=x; part2=y; } void put_marks() { cout<<"Marks obtained:"<<"part1="<<part1<<"\n"<<"part2="<<part2<<"\n"; } }; class sports { protected: [...]

C++ program to implement three classes using multiple inheritance

Saturday, March 13th, 2010  »  Posted By Ranjith  »  Total 2 Comments

MULTIPLE INHERITANCES AIM: Write a program to illustrating how all the three classes are implemented in multiple inheritance mode ALGORITHM • Start the process • Invoke the class M • Invoke the another class N • Invoke one more class,ie class P,which is inherited by both M and N • Create an object for class [...]

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup