C Program to create mark sheet of given students
Program
#include <stdio.h>
#include
<stdlib.h>
/*structure
declaration*/
struct student
{
char name[30];
int roll;
float perc;
};
int main()
{
struct student
*pstd;
/*Allocate memory
dynamically*/
pstd=(struct
student*)malloc(1*sizeof(struct student));
if(pstd==NULL)
{
printf("Insufficient
Memory, Exiting... \n");
return 0;
}
/*read and print
details*/
printf("Enter
name: ");
gets(pstd->name);
printf("Enter
roll number: ");
scanf("%d",&pstd->roll);
printf("Enter
percentage: ");
scanf("%f",&pstd->perc);
printf("\nEntered
details are:\n");
printf("Name:
%s, Roll Number: %d, Percentage:
%.2f\n",pstd->name,pstd->roll,pstd->perc);
return 0;
}
Output:
Enter name: Mike Enter roll number: 1
Enter percentage: 87.50 Entered details are:
Name: Mike, Roll Number: 1,
Percentage: 87.50
No comments:
Post a Comment