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 / gaurav
#include <stdio.h>
#include <conio.h>
struct student
{
char name[20],dept[20],course[20];
int roll, year_join;
}stud[450];
void main ()
{
int i,n;
printf("Enter the number of student(s)");
scanf("%d",&n);
printf("Enter the record of student(s)
");
for(i=0;i<n;i++)
{
printf("Enter name");
scanf("%s",&stud[i].name);
printf("Enter Department");
scanf("%s",&stud[i].dept);
printf("Enter Roll no");
scanf("%d",&stud[i].roll);
printf("Enter year of joining");
scanf("%d", &stud[i].year_join);
printf("Enter course");
scanf("%s",&stud[i].course);
}
printf("Data of students are");
for(i=0;i<n;i++)
{
printf("Name of student is %s ",stud[i].name);
printf("Departemt of student is %s ",stud[i].dept);
printf("Roll no of student is %d ",stud[i].roll);
printf("Year of joining is %d ",stud[i].year_join);
printf("Course of student is %s ",stud[i].course);
}
getch();
}
Is This Answer Correct ? | 7 Yes | 8 No |
Post New Answer View All Answers
What is the use of a ‘ ’ character?
How many levels deep can include files be nested?
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
Explain what is a pragma?
What are dangling pointers in c?
What do the functions atoi(), itoa() and gcvt() do?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
hi send me sample aptitude papers of cts?
What is declaration and definition in c?
Why does everyone say not to use scanf? What should I use instead?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
What is a good data structure to use for storing lines of text?
code for quick sort?
Where are c variables stored in memory?
What is the use of bitwise operator?