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
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)
Is null a keyword in c?
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
What is the significance of scope resolution operator?
Write a program to swap two numbers without using the third variable?
Can include files be nested?
What is the use of putchar function?
Lists the benefits of c programming language?
Implement bit Array in C.
What is meant by keywords in c?
How do I convert a string to all upper or lower case?
What is the use of parallelize in spark?
provide an example of the Group by clause, when would you use this clause
What is the difference between strcpy() and memcpy() function in c programming?
What are integer variable, floating-point variable and character variable?