- #include<stdio.h>
- #include<stdlib.h>
- struct Book
- {
- int *ptr;
- char Name[50];
- int Pages;
- float Price;
- }x[100];
- int main()
- {
- int i,n;
- printf("Enter no. of books: ");
- scanf("%d",&n);
- x[i].ptr=(int*)malloc(n*sizeof(int));
- if(x[i].ptr==NULL)
- {
- printf("Memory not allocated");
- }
- else{
- printf("Enter Book details: ");
- for(i=0;i<n;i++)
- {
- printf("\nEnter Name: ");
- scanf("%s",&x[i].Name);
- printf("Enter pages: ");
- scanf("%d",&x[i].Pages);
- printf("Enter Price: ");
- scanf("%f",&x[i].Price);
- }
- for(i=0;i<n;i++)
- {
- printf("\nThe details of book are: ");
- printf("\nName: %s ",x[i].Name);
- printf("\nPages:%d ",x[i].Pages);
- printf("\nPrice:%f",x[i].Price);
- }
- }
- }
