Ques 1. WAP To Read Marks of N (Eg. 5) Students and Store Them Under An Array. Also Display Them
Ques 1. WAP To Read Marks of N (Eg. 5) Students and Store Them Under An Array. Also Display Them
Solution: //programe to show the use of an array #include<iostream.h> #include<conio.h> void main() { clrscr() long int mar!s"#$ cout<<%&nter the mar!s ' % for (int i'( i<') **i) { cin>>mar!s"i$ + cout<<%,ar!s : % for (int -'( -<') **-) { cout<<%.n%<<mar!s"-$ + getch() +
/utput:
Ques 2. WAP to accept marks of n students from the user and find their sum and average. Soluiton: //programe to show the sum and array of mar!s of the students #include<iostream.h> #include<conio.h> void main() { clrscr() long int mar!s"0(($1 sum'(1 avg1 n cout<<%&nter the num2er ' % cin>>n cout<<%&nter the mar!s ' % for (int i'( i<'n **i) { cin>>mar!s"i$ sum ' sum * mar!s"i$ + avg ' sum / # cout<<%3he sum ' %<<sum<<%.n% cout<<%3her average ' %<<avg getch() +
/utput:
Ques . WAP to count the num!er of employees earning more then 1 lakh per annum. "he monthly salary of n users is entered from key!oard. Solution: //programe to count the salary #include<iostream.h> #include<conio.h> void main() { clrscr() int a"0(($1 count ' (1 21 n cout<<%&nter the num2er ' % cin>>n cout<<%&nter the elements ' % for (int i'( i<'n **i) { cin>>a"i$ + for (int -'( -<'n **-) { 2 ' a"-$ 4 05 if (2 > 0((((() { **count + +
/utput:
Ques #. WAP to read a set of n num!ers from the key!oard and find out the largest num!er in the given array. Solution: //programe to find the largest #include<iostream.h> #include<conio.h> void main() { clrscr() int large1 a"0(($1 n cout<<%&nter the limit ' % cin>>n cout<<%&nter the num2er ' % for (int i'( i<'n60 **i) { cin>>a"i$ + large ' a"($ for (int -'0 -<'n60 **-) { if (large < a"-$) large ' a"-$ + cout<<%3he largest num2er ' %<<large getch()
/utput:
Ques 5. WAP to read a set of num!ers from the key!oard and sort them in ascending order. Solution: //programe to show the use of 2u22le sort #include<iostream.h> #include<conio.h> void main() { clrscr() int temp1 a"#$1 n cout<<%&nter the limit ' % cin>>n cout<<%&nter the elements ' % for (int i'( i<'n60 **i) { cin>>a"i$ + cout<<%&lements 2efore sorting% for (int !'( !<'n60 **!) { cout<<%.n%<<a"!$ + for (int l'( l<'n65 **l) { for (int -'( -<(n606l) **-)
{ if (a"-$ > a"-*0$) { temp ' a"-$ a"-$ ' a"-*0$ a"-*0$'temp + + + cout<<%.n%<<%&lements after sorting% for (int m'( m<'n60 **m) { cout<<%.n%<<a"m$ + getch() +
/utput: