Structure

Structure = Assign value in structure data type
1.
Struct a
{
Int x
Char y
}B={4,n};// Declaire Variable and assign values



Video





#include<stdio.h>
struct book input(void); // declaire structure return function
struct book // here ";" not available
{
  int BI;
  char BN[10];
  float BP;
}; // here ";" Is Awailable
void main()
{
  struct book B1; // must use struct before datatype
  B1=input();
  display();
 
}
struct book input() // use return type
{
  struct book B2;
  printf("enter the Book Id\n");
  scanf("%d",&B2.BI);
  printf("enter the name of book\n");
  fflush(stdin);
  gets(B2.BN);
  printf("entert Book Price\n");
  scanf("%f",&B2.BP);
  return B2;
}
void display(struct book B1) // use of input
{
  printf("book id = %d\n book name= %s \n book price=%f",B1.BI,B1.BN,B1.BP);
}


Comments