Sign in to follow this  
memesgaming

C structure sample code

Recommended Posts

#include

#include

 

struct student {

   char  name[30];

 float percent;

   int   roll_no;

};

 

int main( ) {

typedef struct student STU ;

 STU s1, s2;      

 

 

   strcpy( s1.name, "youre name");

    s1.percent = 95.78;

   s1.roll_no = 163;

 

   

    strcpy( s2.name, "onother name");

    s2.percent = 96.57;

   s2.roll_no = 87000;

 

 

   

   printf( "student 1 name : %s\n", s1.name);

   printf( "Grade : %.2f \n", s1.percent);

   printf( "Student number : %d\n", s1.roll_no);

 

 

  printf(" \n ");

 

printf("student 2 name : %s\n", s2.name);

   printf( "Grade : %.2f \n", s2.percent);

   printf( "Student number : %d\n", s2.roll_no);

 

   return 0;

}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this