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


Please Help Members By Posting Answers For Below Questions

In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

1635


Is null a keyword in c?

739


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1523


What is the significance of scope resolution operator?

865


Write a program to swap two numbers without using the third variable?

601






Can include files be nested?

631


What is the use of putchar function?

654


Lists the benefits of c programming language?

600


Implement bit Array in C.

678


What is meant by keywords in c?

620


How do I convert a string to all upper or lower case?

631


What is the use of parallelize in spark?

580


provide an example of the Group by clause, when would you use this clause

1711


What is the difference between strcpy() and memcpy() function in c programming?

629


What are integer variable, floating-point variable and character variable?

611