Showing posts with label PROGRAM USING STRUCTURES AND UNIONS. Show all posts
Showing posts with label PROGRAM USING STRUCTURES AND UNIONS. Show all posts

Thursday, January 29, 2015

PROGRAM USING STRUCTURES AND UNIONS

PROGRAM:

#include<stdio.h> struct student

{

int rno,m1,m2,m3; float avg;

char name[20],dept[10];
};

main()
{

struct student s;

printf("Enter the Student Details:\n"); printf("Enter the Stuent roll no:\n");

scanf("%d",&s.rno);

printf("Enter the Stuent Name:\n"); scanf("%s",&s.name); printf("Enter the Stuent Dept:\n"); scanf("%s",&s.dept);

printf("Enter the 3 marks:\n"); scanf("%d%d%d",&s.m1,&s.m2,&s.m3);
s.avg=(s.m1+s.m2+s.m3)/3;
printf("The Student Average is :%f\n",s.avg);

}


OUTPUT:

Enter the Student Details: Enter the Stuent roll no: 12

Enter the Stuent Name: Kumar

Enter the Stuent Dept: CSE

Enter the Stuent marks: 40 18 90


The Student Average is :49.000000