Articles added in Mathematics Lab | Cyber Lab is now open | Astronomy Lab is now open | VLSI Lab is now open | 120 SEO Tips article published | More exciting articles coming soon!




Array of Structures

Consider the following declarations:

Struct complex
{
float a;
float b;
};
complex c[100]; //Here c is an array of structures of type complex.
c[0], c[1], c[2], . . .c[99] are structures of type complex.

To access members of c[0]:
c[0].a and c[0].b

Reading 100 complex numbers:
for(i=0; i<100; i++)
cin>>c[i].a>>c[i].b;

Displaying 100 complex numbers:
for(i=0; i<100; i++)
cout << c[i].a << ā€+Iā€ << c[i].b << endl;









CACKLE comment system





Programming Resources
Computer Networking Fundamentals Android Application