Sunday, November 17, 2019

Program for Structure

#include<stdio.h>
#include<conio.h>
structure student
{
char name[15];
int roll,m1,m2,m3,total;
float per;
}z;
void main()
{

 printf("Enter Name:");
 scanf("%s",&z.name);
 printf("\nEnter Roll Number:");
 scanf("%d",&z.roll);
 printf("\nEnter Marks of Mathematics:");
 scanf("%d",&z.m1);
 printf("\nEnter Marks of C Programming:");
 scanf("%d",&z.m2);
 printf("\nEnter Marks of Fundamental of Computer:");
 scanf("%d",&z.m3);
 z.total=z.m1+z.m2+z.m3;
 z.per=z.total/3;
 printf("***********************************************************");
 printf("\nMarksheet\n");
 printf("\nName:%s",z.name);
 printf("\nRoll Number:%d",z.roll);
 printf("\nMathematics:%d",z.m1);
 printf("\nC Programming:%d",z.m2);
 printf("\nFundamental of Computer:%d",z.m1);
 printf("\nTotal Marks Obtained:%d",z.total);
 printf("\nPercentage:%f",z.per);
 getch();
}

Output:
Enter Name:XYZ                                                                                                                         
                                                                                                                                       
Enter Roll Number:55                                                                                                                   
                                                                                                                                       
Enter Marks of Mathematics:78                                                                                                          
                                                                                                                                       
Enter Marks of C Programming:89                                                                                                        
                                                                                                                                       
Enter Marks of Fundamental of Computer:80                                                                                              
***********************************************************                                                                            
Marksheet                                                                                                                              
                                                                                                                                       
Name:XYZ                                                                                                                               
Roll Number:55                                                                                                                         
Mathematics:78                                                                                                                         
C Programming:89                                                                                                                       
Fundamental of Computer:78                                                                                                             
Total Marks Obtained:247                                                                                                               
Percentage:82.00000

3 comments: