Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
656 B
2
Indexable
// Online C compiler to run C program online
#include <stdio.h>
#include<stdlib.h>
struct student{
    int rollno;
    char name[25];
    int m1;
    int m2;
    int m3;
};
void main() {
   
    struct student *ptr=(struct student*) malloc(1*(sizeof (struct student)));
   scanf("%d",&(ptr)->rollno);
   scanf("%s",(ptr)->name);
   scanf("%d",&(ptr)->m1);
   scanf("%d",&(ptr)->m2);
   scanf("%d",&(ptr)->m3);
   
   int totalmarks= (ptr->m1)+(ptr->m2)+(ptr->m3);
   //print
    printf("%d",(ptr)->rollno);
   printf("\n%s",(ptr)->name);
   printf("\n%d",(ptr)->m1);
   printf("\n%d",(ptr)->m2);
   printf("\n%d",(ptr)->m3);
   printf("\n%d",totalmarks);
}
Leave a Comment