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
explain how do you use macro?
What is c value paradox explain?
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
What is action and transformation in spark?
What is array within structure?
Explain what is output redirection?
Differentiate between the expression “++a” and “a++”?
Write programs for String Reversal & Palindrome check
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
Can you assign a different address to an array tag?
Compare and contrast compilers from interpreters.
What does the message "automatic aggregate intialization is an ansi feature" mean?
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.