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 / dolly kushwah
#include <stdio.h>
struct student
{
int rn;
char name[20];
char course[20];
char dept[20];
int yoj;
} s[450];
displaydata (int rn, int n)
{
for (int i = 0; i < n; i++)
{
(rn == s[i].rn) ? printf ("%s %d %s %s %d
", s[i].name, s[i].rn,
s[i].course, s[i].dept,
s[i].yoj) : printf ("roll no not found..
");
}
}
displayname (int yoj, int n)
{
for (int i = 0; i < n; i++)
{
(yoj ==
s[i].yoj) ? (printf ("%s
",
s[i].
name))
: (printf ("no students who are joinig in year %d
", yoj));
}
}
int
main ()
{
int rn, yoj, n, i = 0;
printf ("Enter the no of students...
");
scanf ("%d", &n);
printf ("Enter the name , roll no.,couse, dept , year of joining....
");
for (int i = 0; i < n; i++)
{
scanf ("%s%d%s%s%d", &s[i].name, &s[i].rn, &s[i].course, &s[i].dept,
&s[i].yoj);
}
printf ("Enter the year of joining of students...
");
scanf ("%d", &yoj);
displayname (yoj, n);
printf ("Enter the roll no of students...
");
scanf ("%d", &rn);
displaydata (rn, n);
return 0;
}
| Is This Answer Correct ? | 4 Yes | 5 No |
Post New Answer View All Answers
write a program to copy the string using switch case?
Who is the founder of c language?
pierrot's divisor program using c or c++ code
Explain how many levels deep can include files be nested?
can we change the default calling convention in c if yes than how.........?
What is a const pointer?
What do you understand by normalization of pointers?
What are two dimensional arrays alternatively called as?
What is the use of a static variable in c?
What do header files do?
Explain how do you convert strings to numbers in c?
What is the use of define in c?
how to write optimum code to divide a 50 digit number with a 25 digit number??
What is the use of extern in c?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com