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


Please Help Members By Posting Answers For Below Questions

How can you tell whether a program was compiled using c versus c++?

622


What will be your course of action for a push operation?

669


Explain what are the different file extensions involved when programming in c?

638


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

631


Can an array be an Ivalue?

668






What is quick sort in c?

588


Can we replace the struct function in tree syntax with a union?

784


Explain what are linked list?

628


Is there sort function in c?

581


write a c program in such a way that if we enter the today date the output should be next day's date.

1685


What is a macro, and explain how do you use it?

631


Why void main is used in c?

562


Differentiate between the = symbol and == symbol?

720


What does c mean in basketball?

563


write a c program for swapping two strings using pointer

2097