Saturday, 28 May 2016

Q: Write a program that uses two arrays to store the roll number and marks of students. it inputs roll numbers and marks of five students and stores them in corresponding elements of the arrays. The program finally displays the roll number and marks of the students with highest marks.

Program:

#include<iostream.h>
#include<conio.h>
void main()
{
  int rno[5], marks[5];
  int i;
  cout<<"Enter roll number and marks of student:";
  for(i=0;i<5;i++)
  cin>>rno[i]>>marks[i];
  max=0;
  for(i=1;i<5;i++)
  if(marks[i]>marks[max])
  max=i;
cout<<" The student with highest marks:"<<endl;
cout<<" Roll Number: "<<rno[max]<<endl;
cout<<" Marks: "<<marks[max];
getche();
}


No comments:

Post a Comment