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

#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }

668


What is the difference between pure virtual function and virtual function?

654


Are c and c++ the same?

629


What are the keywords in c?

645


Explain is it valid to address one element beyond the end of an array?

739






How can I automatically locate a programs configuration files in the same directory as the executable?

634


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

1858


What do you mean by c what are the main characteristics of c language?

575


What are the three constants used in c?

549


Write a program to reverse a string.

644


Write a program to check prime number in c programming?

601


What is the sizeof () a pointer?

552


What does. int *x[](); means ?

640


What is context in c?

543


What is pass by reference in c?

617