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 s1;
printf ("Enter name, ID, department, course, year : ");
scanf("%s%d%s%s%d",&s1.name,&s1.roll_no,&s1.department,&s1.course,&s1.year);
printf("And here is whhat you have entered\n");
printf("Name = %s\n\nRoll No. = %d\n\nDepartment = %s\n\nCopurse = %s\n\nYear = %d\n\n",s1.name,s1.roll_no,s1.department,s1.course,s1.year);
system("pause");
return 0;
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.