Md Nayeem

Md Nayeem

  • NA
  • 75
  • 22.8k

Where is the problem in this code?

Jan 16 2018 3:31 PM
  1. #include <stdio.h>  
  2.   
  3. struct Bookinfo  
  4. {  
  5.       char[20] bname;  
  6.       int pages;  
  7.       int price;  
  8. }book[3];  
  9.   
  10. int main(int argc, char *argv[])  
  11. {  
  12. int i;  
  13.   
  14. for(i=0;i<3;i++)  
  15.     {  
  16.     printf("\nEnter the Name of Book    : ");  
  17.     gets(book[i].bname);  
  18.     printf("\nEnter the Number of Pages : ");  
  19.     scanf("%d",book[i].pages);  
  20.     printf("\nEnter the Price of Book   : ");  
  21.     scanf("%f",book[i].price);  
  22.     }      
  23.   
  24. printf("\n--------- Book Details ------------ ");  
  25.       
  26. for(i=0;i<3;i++)  
  27.     {  
  28.     printf("\nName of Book    : %s",book[i].bname);  
  29.     printf("\nNumber of Pages : %d",book[i].pages);  
  30.     printf("\nPrice of Book   : %f",book[i].price);  
  31.     }      
  32.   
  33. return 0;  
  34. }  

Answers (1)