//========================
//Program in C to learn structures in C, struct2.c
//========================
#include<stdio.h>
int main()
{
struct book
{
char title;
int page;
float price;
};
struct book b1,b2,b3;
printf("\n Enter the title, page and price for the first book \n");
scanf("%c %d %f",&b1.title, &b1.page, &b1.price);
printf("\n Details of first book are: %c %d %f \n",b1.title,b1.page,b1.price);
printf("\n Enter the title, page and price for the Second book \n");
scanf("%c %d %f",&b2.title, &b2.page, &b2.price);
printf("\n Details of first book are: %c %d %f \n",b2.title,b2.page,b2.price);
printf("\n Enter the title, page and price for the third book \n");
scanf("%c %d %f",&b3.title, &b3.page, &b3.price);
printf("\n Details of first book are: %c %d %f \n",b3.title,b3.page,b3.price);
return 0;
}
//Program in C to learn structures in C, struct2.c
//========================
#include<stdio.h>
int main()
{
struct book
{
char title;
int page;
float price;
};
struct book b1,b2,b3;
printf("\n Enter the title, page and price for the first book \n");
scanf("%c %d %f",&b1.title, &b1.page, &b1.price);
printf("\n Details of first book are: %c %d %f \n",b1.title,b1.page,b1.price);
printf("\n Enter the title, page and price for the Second book \n");
scanf("%c %d %f",&b2.title, &b2.page, &b2.price);
printf("\n Details of first book are: %c %d %f \n",b2.title,b2.page,b2.price);
printf("\n Enter the title, page and price for the third book \n");
scanf("%c %d %f",&b3.title, &b3.page, &b3.price);
printf("\n Details of first book are: %c %d %f \n",b3.title,b3.page,b3.price);
return 0;
}
No comments:
Post a Comment