Pointer to a structure in C.

 

01  #include <stdio.h>
02
03 struct student
04 {
05 char name[30];
06 int roll_no;
07 float cgpa;
08 };
09
10 int main()
11 {
12 struct student s={"Sumit",1020,8.8};
13
14 struct student *ptr=&s;
15
16 printf("nStudent Details :");
17 printf("nName : %s",ptr->name);
18 printf("nRoll No. : %d",ptr->roll_no);
19 printf("nCGPA : %.2f",ptr->cgpa);
20
21 return 0;
22 }
 
 OUTPUT :

Student Details :");
Name : Sumit
Roll No. : 1020
CGPA : 8.80

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.