EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

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];
10      int rollno;
11      float marks;
12    };
13    struct student s1,s2,s3,s4,s5;
14    printf("\nEnter the name, dept, roll number and marks of five students:\n");
15    scanf("%s %s %d %f",&s1.name,&s1.dept,&s1.rollno,&s1.marks);
16    scanf("%s %s %d %f",&s2.name,&s2.dept,&s2.rollno,&s2.marks);
17    scanf("%s %s %d %f",&s3.name,&s3.dept,&s3.rollno,&s3.marks);
18    scanf("%s %s %d %f",&s4.name,&s4.dept,&s4.rollno,&s4.marks);
19    scanf("%s %s %d %f",&s5.name,&s5.dept,&s5.rollno,&s5.marks);
20    printf("\nThe name, dept, roll number and marks of five students are:");
21    printf("\n%s %s %d %f",s1.name,s1.dept,s1.rollno,s1.marks);
22    printf("\n%s %s %d %f",s2.name,s2.dept,s2.rollno,s2.marks);
23    printf("\n%s %s %d %f",s3.name,s3.dept,s3.rollno,s3.marks);
24    printf("\n%s %s %d %f",s4.name,s4.dept,s4.rollno,s4.marks);
25    printf("\n%s %s %d %f",s5.name,s5.dept,s5.rollno,s5.marks);
26    getch();
27  }

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