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 book
{
int roll;
char name[20];
char department[20];
char course[20];
int year;
}b;
int main ()
{
printf ("Enter roll no. : ");
scanf ("%d",&b.roll);
fflush (stdin);
printf ("Enter name: ");
gets (b.name);
fflush (stdin);
printf ("Enter department: ");
gets (b.department);
fflush (stdin);
printf ("Enter course: ");
gets (b.course);
printf ("Enter year: ");
scanf ("%d",&b.year);
printf("\nRoll number: %d\nName: %s\nDepartment: %s\nCourse: %s\nYear: %d\n",b.roll,b.name,b.department,b.course,b.year);
printf ("\npress any key to close.");
getch();
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.