| 1. |
(a) Write a C++ program to store and print information (name, roll and marks) of a student using structure.(b) Write a program in C++ to input the total marks obtained by a group of students in a class and display them in descending order using pointer. |
|
Answer» (a) #include<iostream> (b) #include<iostream> int main () { cout<<"Enter how many student"; cin>>n; for(i=0;i<n;i++) { cout<<"Enter mark"<<i+1<<";"; cin>>*(ptr++) } for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(mark[i]>mark[j]) { temp = mark[i]; mark[i] = mark[j]; mark[j] = temp; } ptr = mark; cout<<"The marks in descending order"; for(i=0;j<n;i++) cout<<*(ptr++)<<endI; } |
|