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

What is infinite loop?

635


Explain can static variables be declared in a header file?

691


What is pragma c?

627


any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above

638


What is an example of structure?

596






Explain what does the function toupper() do?

640


Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.

1774


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

676


4. main() { int c=- -2; printf("c=%d",c); }

1375


Why c is called a middle level language?

640


Explain heap and queue.

593


Why is c fast?

614


How can I implement sets or arrays of bits?

613


Why c is faster than c++?

639


Why should I use standard library functions instead of writing my own?

687