C++, Programmimg Languages

Write a program in C++ to enter the roll no., name and marks of 5 students using structure

#include<iostream.h>

#include<conio.h>

struct student

{

int rollno;

char name[20];

int marks;

};

void main()

{

student std[10];

int i,n;

cout<<“Enter the no. of students”;

cin>>n;
cout<<“Enter the values:”;

for(i=0;i<n;i++)

{

cout<<“Enter the Roll no.”;

cin>>std[i].rollno;

cout<<“Enter the Name”;

cin>>std[i].name;

cout<<“Enter the marks”;

cin>>std[i].marks;

}

cout<<“Display the values”;

for(i=0;i<n;i++)

{

cout<<std[i].rollno<<‘\t’;

cout<<endl<<std[i].name<<‘\t’;
cout<<endl<<std[i].marks<<‘\t’;
}

getch();

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s