Problem:- Write A Program To Create Array of Structure in C Language or how to create an array of structures in c or Array of structures in C or How do you make an array of structs in C? or C array of structure or Array of Structure in C Programming or Array of Structure in C, Array within Structure in C or C Program to Store Information of Students Using Structure or Example of using array of structure or How to create an empty array of structs?.
Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.
What Is An Array?
An Array is a collection or group of similar data type. or we can say that an array is used to store the similar data or same type of data. An Array index starts with zero and ends with n-1 here n is a size of an array.
What Is Structure
The structure is a user-defined data type in C which allows you to combine different data types to store a particular type of record. The structure is used to represent a record. Suppose you want to store a record of Student which consists of student name, address, roll number and age.
Defining a structure
struct keyword is used to define a structure. struct define a new data type which is a collection of different type of data.
Syntax :
struct structure_name
{
//Statements
};
Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.
Solution:-
#include<stdio.h>
#include<conio.h>
struct student
{
int roll_no;
char name[15];
};
int main()
{
int counter;
int size=3;
struct student s[size];
for(counter=0;counter<3;counter++)
{
printf("Enter The Name And Roll No. of Student %d\n",counter+1);
scanf("%s%d",s[counter].name,&s[counter].roll_no);
}
printf("\n\n");
for(counter=0;counter<3;counter++)
{
printf("Name \t%s\t Roll no. \t%d\n",s[counter].name,s[counter].roll_no);
}
}
Output:-
You May Also See
1. C Program For Convert Binary Number to Decimal or Decimal Number to Binary Using Function
2. C Program For Convert Octal Number to Decimal and Vice Versa Using Function
3. C Program For Convert Binary to Octal and Vice Versa Using Function
4. C Program to Display Prime Numbers Between Intervals Using Using Function
5. C Program to Check Prime or Armstrong Number Using Function
6. C Program For Reverse A String Using Pointer
7. C Program For Compare Two String Using Pointer
8. C Program For Open A File (Or Open A Program Itself ) Using Pointer
9. C Program To Store Student Information Like (Name, Roll & Marks) In C Using Structure
10. C Program To Store Students Information of Using Structure In C
Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.
What Is An Array?
An Array is a collection or group of similar data type. or we can say that an array is used to store the similar data or same type of data. An Array index starts with zero and ends with n-1 here n is a size of an array.
What Is Structure
The structure is a user-defined data type in C which allows you to combine different data types to store a particular type of record. The structure is used to represent a record. Suppose you want to store a record of Student which consists of student name, address, roll number and age.
Defining a structure
struct keyword is used to define a structure. struct define a new data type which is a collection of different type of data.
Syntax :
struct structure_name
{
//Statements
};
Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.
Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.
Solution:-
#include<stdio.h>
#include<conio.h>
struct student
{
int roll_no;
char name[15];
};
int main()
{
int counter;
int size=3;
struct student s[size];
for(counter=0;counter<3;counter++)
{
printf("Enter The Name And Roll No. of Student %d\n",counter+1);
scanf("%s%d",s[counter].name,&s[counter].roll_no);
}
printf("\n\n");
for(counter=0;counter<3;counter++)
{
printf("Name \t%s\t Roll no. \t%d\n",s[counter].name,s[counter].roll_no);
}
}
Output:-
You May Also See
1. C Program For Convert Binary Number to Decimal or Decimal Number to Binary Using Function
2. C Program For Convert Octal Number to Decimal and Vice Versa Using Function
3. C Program For Convert Binary to Octal and Vice Versa Using Function
4. C Program to Display Prime Numbers Between Intervals Using Using Function
5. C Program to Check Prime or Armstrong Number Using Function
6. C Program For Reverse A String Using Pointer
7. C Program For Compare Two String Using Pointer
8. C Program For Open A File (Or Open A Program Itself ) Using Pointer
9. C Program To Store Student Information Like (Name, Roll & Marks) In C Using Structure
10. C Program To Store Students Information of Using Structure In C
0 Comments: