Tuesday, 13 April 2021

Structure in C and C++ - 3

 #include<iostream.h>

#include<conio.h>

struct Book

{

char code;

int pages;

float price;

};

int main()

{

clrscr();

Book b[3];

cout<<sizeof(b)<<endl;

int i;

for(i=0;i<3;i++)

{

cout<<"Enter book code, pages and price\n";

cin>>b[i].code>>b[i].pages>>b[i].price;

}

for(i=0;i<3;i++)

cout<<"Code="<<b[i].code<<" Pages="<<b[i].pages<<" Price="<<b[i].price<<endl;

getch();

return 0;


}

No comments:

Post a Comment