Q2. Write a program to define four structures with structure variable of array types. Enter data into each structure variable that has four records and each record contains five fields.
#include <iostream>
struct Struct1
{
int a[5];
int b[5];
int c[5];
int d[5];
};
using namespace std;
int main()
{
struct Struct1 s;
cout<<"Enter details for a: \n";
for(int i=0;i<5;i++)
cin>>s.a[i];
cout<<"Enter details for b: \n";
for(int i=0;i<5;i++)
cin>>s.b[i];
cout<<"Enter details for c: \n";
for(int i=0;i<5;i++)
cin>>s.c[i];
cout<<"Enter details for d: \n";
for(int i=0;i<5;i++)
cin>>s.d[i];
return 0;
}
Comments
Leave a comment