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 / mrityunjay yadav
#include<stdio.h>
struct students
{
int Roll_no;
char name[50];
char deptt[20];
char course[30];
int year_of_passing;
};
void main()
{
struct students s[500];
int n,i,year,rollno,ccy,found=0;
clrscr();
printf("\nEnter number of students : ");
scanf("%d",&n);
printf("\nEnter the course completion period(in years) : ");
scanf("%d",&ccy);
printf("\nEnter student details : \n");
for(i=0;i<n;i++)
{
printf("\n\nEnter details for student : %d",i+1);
printf("\nRoll No : ");
scanf("%d",&s[i].Roll_no);
printf("\nName : ");
scanf("%s",s[i].name);
printf("\nDepat. : ");
scanf("%s",s[i].deptt);
printf("\nCourse : ");
scanf("%s",s[i].course);
printf("\nYear of Passing : ");
scanf("%d",&s[i].year_of_passing);
}
printf("\nQuestion 1 -> Enter the year of joining : ");
scanf("%d",&year);
printf("\nName of the Students\n------------------------------…
for(i=0;i<n;i++)
{
if(s[i].year_of_passing==(ccy+year))
{
printf("\n%s",s[i].name);
found=1;
}
}
if(found==1);
else printf("\nNo record Found\n");
found=0;
printf("\nQuestion 2 -> Enter the roll no : ");
scanf("%d",&rollno);
if(s[i].Roll_no==rollno)
{
found=1;
printf("\nName : %s\nDept. : %s\nCourse :
%s\n",s[i].name,s[i].deptt,s[i].course);
}
if(found==1);
else printf("\nNo record Found\n");
getchar();
}
Is This Answer Correct ? | 29 Yes | 25 No |
Post New Answer View All Answers
What is the use of getchar() function?
If fflush wont work, what can I use to flush input?
What will the preprocessor do for a program?
Dont ansi function prototypes render lint obsolete?
How we can insert comments in a c program?
What is the use of printf() and scanf() functions?
What is a nested loop?
What is chain pointer in c?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58
ATM machine and railway reservation class/object diagram
Can you define which header file to include at compile time?
What is the easiest sorting method to use?
Explain what are linked list?
What are conditional operators in C?