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 the name, department, roll number and marks of 5 students using structure and print the details of those students who have scored above 750

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 students are:");
21    if(s1.marks>750)
22      printf("\n%s %s %d %f",s1.name,s1.dept,s1.rollno,s1.marks);
23    if(s2.marks>750)
24      printf("\n%s %s %d %f",s2.name,s2.dept,s2.rollno,s2.marks);
25    if(s3.marks>750)
26      printf("\n%s %s %d %f",s3.name,s3.dept,s3.rollno,s3.marks);
27    if(s4.marks>750)
28      printf("\n%s %s %d %f",s4.name,s4.dept,s4.rollno,s4.marks);
29    if(s5.marks>750)
30      printf("\n%s %s %d %f",s5.name,s5.dept,s5.rollno,s5.marks);
31    getch();
32  }

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