Write a program to input and print name, department, roll number and marks of five students using structure
|
Source Code
#include<stdio.h>
#include<conio.h>
int main (int argc, char *argv[])
{
clrscr();
struct student
{
char name[100];
char dept[100];
int rollno;
float marks;
};
struct student s1,s2,s3,s4,s5;
printf("\nEnter the name, dept, roll number and marks of five students:\n");
scanf("%s %s %d %f",&s1.name,&s1.dept,&s1.rollno,&s1.marks);
scanf("%s %s %d %f",&s2.name,&s2.dept,&s2.rollno,&s2.marks);
scanf("%s %s %d %f",&s3.name,&s3.dept,&s3.rollno,&s3.marks);
scanf("%s %s %d %f",&s4.name,&s4.dept,&s4.rollno,&s4.marks);
scanf("%s %s %d %f",&s5.name,&s5.dept,&s5.rollno,&s5.marks);
printf("\nThe name, dept, roll number and marks of five students are:");
printf("\n%s %s %d %f",s1.name,s1.dept,s1.rollno,s1.marks);
printf("\n%s %s %d %f",s2.name,s2.dept,s2.rollno,s2.marks);
printf("\n%s %s %d %f",s3.name,s3.dept,s3.rollno,s3.marks);
printf("\n%s %s %d %f",s4.name,s4.dept,s4.rollno,s4.marks);
printf("\n%s %s %d %f",s5.name,s5.dept,s5.rollno,s5.marks);
getch();
}
Find More from our code collection
Armstrong number, binary number to a decimal number, bubble sort, decimal number to binary number, factorial of the given number
factors, fibonacci numbers, HCF and LCM, matrix, mergesort, salary of the employee.
palindrome, quadratic equation, star patterns, series etc. and much more...
Return to Example Source Code