0% found this document useful (0 votes)
34 views

Ques 1. WAP To Read Marks of N (Eg. 5) Students and Store Them Under An Array. Also Display Them

The document contains solutions to 5 questions involving arrays in C programming. Each question asks the user to write a program to perform some operation on an array such as reading and displaying student marks, calculating sum and average of marks, counting employees earning over a certain salary, finding the largest number in an array, and sorting numbers in an array in ascending order. The solutions provided use basic array operations like input, output, loops and if-else conditions to solve each problem.

Uploaded by

Simranjeet Kaur
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Ques 1. WAP To Read Marks of N (Eg. 5) Students and Store Them Under An Array. Also Display Them

The document contains solutions to 5 questions involving arrays in C programming. Each question asks the user to write a program to perform some operation on an array such as reading and displaying student marks, calculating sum and average of marks, counting employees earning over a certain salary, finding the largest number in an array, and sorting numbers in an array in ascending order. The solutions provided use basic array operations like input, output, loops and if-else conditions to solve each problem.

Uploaded by

Simranjeet Kaur
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 12

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 + +

cout<<%3he people having salary a2ove 0 la!h ' %<<count getch() +

/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:

You might also like