Professional Documents
Culture Documents
Question 2 page 97
write a program that take input of ID,age, name & marks of candidates only
store the record of those candidates whose age is less than 20 also display the
candidate's serial number where total number of candidates are 10 using
Arrays in C++
Solution
#include <iostream.h>
main()
int
i=0,ageTemp=0,marksTemp=0,ageR=20,candidateIDTemp=0;
int age[100],marks[100],candidateID[100];
while(i<10)
if(ageTemp<=ageR)
{
candidateID[i]=candidateIDTemp;
age[i]=ageTemp;
marks[i]=marksTemp;
i++;
cout<< "candidateID\t\tage\tMark\n";
for(int j=0;j<i;j++)
cout<<
candidateID[j]<<"\t"<<age[j]<<"\t"<<marks[j]<<"\n";
return 0;
Question 3 page 97
Write a recursive function that finds and returns the minimum element in
an array, where the array and its size are given as parameters.
#include <iostream.h>
{
if (size == 0)
return arr[0];
else
int main(){
int size;
cin>>size;
cin>>arr[i];
}
cout<<"\nMinimum number is : "<<min(arr,size)<<endl;
return 0;