Problem
Create a structure to specify data on students given below:- Roll number
- Name
- Department
- Course
- Year of joining
Solution - Code
#include<stdio.h>#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct stud
{
char name[30];
int roll_no;
char department[30];
char course[30];
int year;
}
int main()
{
struct stud s[5];
int i;
for (i=0;i<5;i++)
{
printf ("Enter name, ID, department, course, year : ");
scanf("%s%d%s%s%d",&s[i].name,&s[i].roll_no,&s[i].department,&s[i].course,&s[i].year);
}
for (i=0;i<5;i++)
{
printf("And here is whhat you have entered\n\n");
printf("Name = %s\n\nRoll No. = %d\n\nDepartment = %s\n\nCopurse = %s\n\nYear = %d\n\n",s[i].name,s[i].roll_no,s[i].department,s[i].course,s[i].year);
}
system("pause");
return 0;
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.