C LAB‎ > ‎(Sem1) Introduction to C‎ > ‎

WAP using structures to input and display details of student.

posted Nov 18, 2010, 4:37 AM by Neil Mathew   [ updated Nov 18, 2010, 4:45 AM ]

SOURCE CODE:

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
 
struct student
        {
         char name[20];
         float marks;
         int age;
 
        }b1, b2;
        
 
main()
{
        printf("\n Enter Names, Marks & Age of the students: \n");
 
        scanf("%s %f %d",&b1.name,&b1.marks,&b1.age);
        scanf("%s %f %d",&b2.name,&b2.marks,&b2.age);
 
        printf("\n This is what you have entered: \n");
        printf("\n %s %f %d ",b1.name,b1.marks,b1.age);
        printf("\n %s %f %d ",b2.name,b2.marks,b2.age);
 
}
 

 

 

OUTPUT:

 

 Enter Names, Marks & Age of the students: 
Neil 94 18
Bugger 0 100
 
 This is what you have entered: 
 
 Neil 94.000000 18 
 Bugger 0.000000 100 

 

Comments