Q-1: Create a structure to specify data on students given
below:
Roll number, Name, Department, Course, Year of joining
Assume that there are not more than 450 students in the
college.
Answer Posted / ahmed
#include <iostream>
using namespace std;
struct student
{
int roll_num;
int year;
char name[10];
char dept[10];
char course[10];
};
int main()
{
student s[5];
int i,j;
for(i=0;i<5;i++)
{
cout<<"Enter roll number student "<<i+1<<" : ";
cin>>s[i].roll_num;
cout<<"Enter Your name student "<<i+1<<" : ";
cin.ignore();
cin.getline(s[i].name,10);
cout<<"Enter your department student "<<i+1<<" : ";
cin.ignore();
cin.getline(s[i].dept,10);
cout<<"Enter your course student "<<i+1<<" : ";
cin.ignore();
cin.getline(s[i].course,10);
cout<<"Enter year of joining : ";
cin>>s[i].year;
}
for(j=0;j<5;j++)
{
cout<<"Student "<<j+1<<" Details : "<<endl;
cout<<" Roll no. : "<<s[j].roll_num<<endl;
cout<<" Name : "<<s[j].name<<endl;
cout<<" Department : "<<s[j].dept<<endl;
cout<<" Course : "<<s[j].course<<endl;
cout<<" year : "<<s[j].year;
cout<<endl;
cout<<endl;
}
return 0;
}
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
How can I avoid the abort, retry, fail messages?
What is queue in c?
How can I prevent another program from modifying part of a file that I am modifying?
Write a program to reverse a given number in c language?
What are pointers? What are different types of pointers?
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
What is function in c with example?
What is the importance of c in your views?
How to Throw some light on the splay trees?
What do you mean by a sequential access file?
What is scanf () in c?
What are pointers in C? Give an example where to illustrate their significance.
C language questions for civil engineering
When c language was developed?
what is the structure pointer?