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
Are the variables argc and argv are always local to main?
Why doesnt that code work?
What is the role of && operator in a program code?
How are strings stored in c?
a c code by using memory allocation for add ,multiply of sprase matrixes
C language questions for civil engineering
Explain what is gets() function?
praagnovation
How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?
#include
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
Explain how do you print an address?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
hi folks i m approching for h1 b interview on monday 8th of august at montreal and i m having little problem in my approval notice abt my bithdate my employer has made a mistake while applying it is 12th january and istead of that he had done 18 the of january do any body have any solution for that if yes how can i prove my visa officer abt my real birthdate it urgent please let me know guys thaks dipesh patel