TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Friday 15 May 2020

C Array Of Structure | C Array Of Structure In Hindi | C Array Of Structure Example | C Programming Array Structure

C Array of Structure


Why use an array of structures? 


An array of structres in C can be defined as the collection of multiple structures variables where each variable contains information about different entities. The array of structure in c are used to store information about multiple entities of different data types. The array of structures is also known as the collection of structures.


image of array structure in c

Fig: Array structure in c


Program of array of structure

 

#include<stdio.h>  

struct student  

{  

    char name[20];  

    int id;  

    float marks;  

};  

void main()  

{  

    struct student s1,s2,s3;  

    int dummy;  

    printf("Enter the name, id, and marks of student 1 ");  

    scanf("%s %d %f",s1.name,&s1.id,&s1.marks);  

    scanf("%c",&dummy);  

    printf("Enter the name, id, and marks of student 2 ");  

    scanf("%s %d %f",s2.name,&s2.id,&s2.marks);  

    scanf("%c",&dummy);  

    printf("Enter the name, id, and marks of student 3 ");  

    scanf("%s %d %f",s3.name,&s3.id,&s3.marks);  

    scanf("%c",&dummy);  

    printf("Printing the details....\n");  

    printf("%s %d %f\n",s1.name,s1.id,s1.marks);  

    printf("%s %d %f\n",s2.name,s2.id,s2.marks);  

    printf("%s %d %f\n",s3.name,s3.id,s3.marks);  

 

 

Output


Enter the name, id, and marks of student 1 Pramod 90 90 

Enter the name, id, and marks of student 2 Amit90 90 

Enter the name, id, and marks of student 3 Ankit 90 90      

Printing the details....       

Pramod 90 90.000000                         

Amit  90 90.000000                     

Ankit  90 90.000000

 


No comments:

Post a Comment