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
How can you tell whether a program was compiled using c versus c++?
What will be your course of action for a push operation?
Explain what are the different file extensions involved when programming in c?
How do I convert a string to all upper or lower case?
Can an array be an Ivalue?
What is quick sort in c?
Can we replace the struct function in tree syntax with a union?
Explain what are linked list?
Is there sort function in c?
write a c program in such a way that if we enter the today date the output should be next day's date.
What is a macro, and explain how do you use it?
Why void main is used in c?
Differentiate between the = symbol and == symbol?
What does c mean in basketball?
write a c program for swapping two strings using pointer