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


Please Help Members By Posting Answers For Below Questions

What is the use of getchar() function?

637


If fflush wont work, what can I use to flush input?

626


What will the preprocessor do for a program?

598


Dont ansi function prototypes render lint obsolete?

616


How we can insert comments in a c program?

638






What is the use of printf() and scanf() functions?

642


What is a nested loop?

661


What is chain pointer in c?

611


Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

715


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

1128


ATM machine and railway reservation class/object diagram

4811


Can you define which header file to include at compile time?

601


What is the easiest sorting method to use?

642


Explain what are linked list?

631


What are conditional operators in C?

632