You are on page 1of 42
INDEX Oz. Enter name , age and salary and display it by using outside the class member . Q2. Program which gives the squares of all the odd numbers stored in an array . Q3.Program to store numbers in an array and allow user to enter any number which he/she wants to find in array .(Binary Search) Q4,.Program for copy constructor . Qs. Enter numbers in an array in any order and it will give the ‘output of numbers in ascending order . 6. Enter any number from 2 digit to 5 digit and the output will be the sum of all the distinguish digits of the numbers . 7. Enter rows and columns and the output will be the sum of the diagonals. 8. Enter item no. , price and quantity in a class . Qg. Enter any line or character ina file and press * to exit the program . Qao. Program will read the words which starts from vowels stored ina file. Q11. Enter employee no , name , age , salary and store it in a file. Quz. Deleting the information of employee by entering the employee number. 3. Enterany number and its power and the output will the power of the number . ay. Enter 3 strings and the output will show the longest string and the shortest string . 0.15 Enterany number and the output will be all the prime numbers up to that number . Q16. Selection sort 017. Using loop concept the program will give the output of numbers making a right triangle . 38. Program for Stacks and Queve . O.agEnter two arrays and the output will be the merge of two arrays . Qzo. Sequence sort . Q.SOL QUERIES AND OUTPUT Ox. Enter name , age and salary and display it by using outside the class member . ciostream h> mio b> inclix ine! class abe t ‘iprivate: char n[20}; int a; float sal; public: void getdatal void) { cout<<"inEnter name "s cin=n; cout<<"\nEnter age ": cima; cout<="nEnter salary"; cin>>sal; } void purdata(void) t cout" NAME IS "<< cout<<"nAGE IS "< #include=conio.k> main) int a[20},i,x clrscr(); cout<<"\nEnter no of elements" cin>>x; for(i=O;i>afi); cout: fort nA: "; sixit+) couts<" "< Hincludeali]; 1 cout<<"nin" for(im0sicnsi-) course” "<>n0; high=n-1 while(low<=I &&P=0) mid=(ov-+high)2; ila 10) cout<="inin"e #include Fineludecstring b> class data t char n{20); int ages float sal; public: att} data(char x) int afloat) strepy(0.8); agema; sal=k: data(data &p) strepy(n.p.n); age-p.agei//+20; saly/+1000; display) t couts<"in\nNAME " #include void main a 20) clrsert); couts<"\nEnter no of elements in A"; cin; for(i=Osisnsi-) cout<<"\nEnter no"; cin>>ali]: cout for(i=0:in;i+-+) cout<<" "< main() int a=0,b=0.¢ clrsert): couts<"\nEnter value for A" while(a>0) for(:2>0:) or for(i-a:i~O:i-i/10) =a 10; bebte: asa lO; couts<"inSum of digits "< includeeonio.h> main() int a[1OJ[10} Aisne: clisert): cout<<"\nEnter no of rows "; for inQricrsi+-+) forg-0,5<05+4) © couts<"aEnter no" cin>alilik int sum=0,suml=0; fontiO;ierit) ¢ Hout. ssum-sum tail * iflitj—r- 1) &R ali] >-O) coutpr, cout<="nEnter quantity cin> qty; : Void dd putdatad) t cout<<"ininltem name:"< inelude Binelude main) f char eh; clrsert); cofstream f1("emp"): ‘vimplicit ostream f1; /ifL open("emp",ios:out); explicit cout<<"\nEnter char vwhile(1) ‘infinity { ch=getche{); // to input a single charactor by keybord. itteh="") break; iffch—=13) Fl.close0: ‘igetch()s : OUTPUT inter char My Mane is man een eee re Qao. Program will read the words which starts from vowels stored ina file. ‘ineludeciostream.h> ‘finclude-fstream.h> Sinelude ‘main() t char ch[80]; int ent=| cliser(); ‘stream f1("emp ofstream £2(’temy while(!f1.eof)) t flemchs coute>ch; coute<"a" ineludefstream.h> int row=5 col2; class abe private int empno: char nf20}; int age, float sal: publie: tdatad) char ch; cin get(ch); To empty buffer cout<<"inEnter employee no"; cin=empno; cout<<"InEnter name " cout<<"\nEnter age ": cin~mage; cout<<"\nEnter salary"; cin>>sal; void putdata() gotoxy(col,row cout<="\n"< finclude ffinclude ffineludestdio.h> class abe { private int empno; char n[20}; int age; float sal; public: void getdata() { cours" 5 cin=>empno; -<"\nEnter name "s cir=>sal } void purdata() { int get_empno() ft rete erp; t ee ring abe pp cclrser();, isweam empS.00is:injos:binary) cofstream £2(’temp' ios::outlios::binary) int emp: cout=<"inlaNAMEWAGEWSALARY"; fl.clear); Fl seekg(0); (ifon(i-Oi—AsitH) while(!f1-eoft)) ‘ £1 read{(char*)&p1,sizeofip!)); if{fL.eoti)) break: pI putdataQ); cout<<"\nEnter employee no”: cin>>emp; AL.clear(); AL seekg(0); ‘while( El) while(!i1.eof0) t Fl rwad((char*)&p L sizeofip1)); if{f1 cof) break; iffemp!=pl get_empno()) 1owitet(char*)&p1 sizeof{p!)); } Al.close(; Bcloses remove("“empS..xt"); rename("temp""emp5.txt"); £.open("empS.txt",jossinjios::binary); cout<<"\ninNAMEWAGI Al.seeker(| (ifaw imOi3;+4) while(!f1.¢e0f)) fl read((char*)&p 1,sizeot{p!)); if{fl.cofl)) break; pl-putdatat) } fl.close(); etch, } OUTPUT ae Cy a3. Enter any number and its power and the output will the power of the number . ineludeciostream h> #ineludeceonio b> finclude includesconio he #ineludecstrin main() { char n{20},1[20}.2120); int 1.1213; clrser(): couts<"inEnter String! *; cin cout<<"inEnter String? *; cin>>al couts<"inFnter String3 *; cin>>n2; =sirlen(a); 2=strlen(al B=strlen(n2), (S12 && 11513) Poout<"nLong: "< include int nig; clrsert) cout for(i=lsic=nit+) \nEnter no of N" po) for iat) Ai%j—=0) pels if_p=0) cout” Nec gotch(); OUTPUT Q16. Selection sort #includesiostream.h> include void main) int a{20].n,ij,tmin.p; cout<<"\nEnter no "; include=conio.h main) int ii clrser(): for(i= zis) coute<"\nin": forti=Lie=i etch); OUTPUT 16 19 16 16 10 16 10 10 10 10_ Q38. Program for Stacks and Queue . fincludesiostream.h> include incl ude>ch; switel(eh) f case 1: cout=<"\nEnter no for insert"; cin>>a, insert(a); break; case 2; delnode()s break; case 3: display(): break; case 4: exit(0); } ' while(1); getch(): ' void insert(int no) // char sti] 1 queue *ptr, ptr-new queue; —_// strepy(ptr>n.str) J plrGtruct queue*)malloc(sizeofstruct queue)); ptr>x=no; ptr->next=NULL; front=ptr; rear-ptr; else rear->next=ptr, rear=ptr: } ) void delnode() intp queue "ptr, cout<"\ninQueue is Empty return; {istepy(p.tront->n) delete pi, cour<"inindeleted clement "< # include ‘main() { int arr1[100},arr2{100},arF3{100}c,i-0,j~0.k=0 size size2; clisex(); ccaut<"in enter no of element of arr! "; for (POjsizelsi++) ¢ cout<<"in enter no. "; cin>>artl [ils } ccout<<"in enter no of element of arr2 "; cin>>size2; for (-O5i>ard[i)s cours<"in al"; for(-O3i void main() clrsext): cout<<"\nEnter no of elements in A" Forti=0; fori-Qsi

You might also like