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
What are the differences between new and malloc in C?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
Why is c faster?
What is the function of volatile in c language?
Explain how can you tell whether a program was compiled using c versus c++?
What are structure members?
What is switch in c?
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
How do you determine whether to use a stream function or a low-level function?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
When can you use a pointer with a function?
How can my program discover the complete pathname to the executable from which it was invoked?
difference between Low, Middle, High Level languages in c ?
Is this program statement valid? INT = 10.50;
Explain a file operation in C with an example.