Search This Blog

Pages

Saturday, January 29, 2011

LabTask1.3

--------------------
/*By Subodh Dahal*/

--------------------


#include <iostream.h>
#include <iomanip.h>
#include <conio.h>

int main()
{
int roll[5],age[5];
char name[5][20],check;
int i=0;

while(1)
{
clrscr();
cout<<"Enter name: ";
cin>>name[i];
cout<<"Enter roll no.: ";
cin>>roll[i];
cout<<"Enter age: ";
cin>>age[i];
cout<<"Press y if you want to add other information"<<endl;
cout<<"or press any other key to display the information entered....";
check=getch();
if (check=='y' || check=='Y')
{
i++;
continue;
}
else
break;
}
int n=i;
clrscr();
cout<<"The entered information is: "<<endl<<endl;
cout<<setw(4)<<"S.N."<<setw(15)<<"Roll Number"<<setw(40)<<"Name"<<setw(10)<<"Age"<<endl;
for (i=0; i<=n; i++)
cout<<setw(4)<<i+1<<setw(15)<<roll[i]<<setw(40)<<name[i]<<setw(10)<<age[i]<<endl;
getch();
return(0);
}

No comments:

Post a Comment