38. Program to demonstrate pointer to structure .


Comments

  1. Swati Waghmare11:45 AM

    /*To Display the name of book,pages and price using pointer to structure*/
    #include
    void main()
    {
    struct book
    {
    char name[10];
    float price ;
    int pages;
    }b;
    struct book *p;
    p=&b;
    printf("\n\t Enter name of Book");
    scanf("%s",p->name);
    printf("\n\tEnter price of Book");
    scanf("%f",&p->price);
    printf("\n\tEnter pages of Book");
    scanf("%d",&p->pages);
    printf("\n\tBook name=%s \n\tBook price=%f \n\tBook pages=%d",p->name,p->price,p->pages);
    }

    ReplyDelete
  2. sayali daunde11:56 AM

    /*To Display the name of book,pages and price using pointer to structure*/
    #include
    void main()
    {
    struct book
    {
    char name[10];
    float price ;
    int pages;
    }b;
    struct book *p;
    p=&b;
    printf("\n\t Enter name of Book");
    scanf("%s",p->name);
    printf("\n\tEnter price of Book");
    scanf("%f",&p->price);
    printf("\n\tEnter pages of Book");
    scanf("%d",&p->pages);
    printf("\n\tBook name=%s \n\tBook price=%f \n\tBook pages=%d",p->name,p->price,p->pages);
    }

    ReplyDelete
  3. /*display n,s,id using pointer to structure*/
    #include
    void main()
    {
    struct emp
    {
    char name[10];
    float salary;
    int id;
    }e;
    struct emp *p;
    p=&e;
    printf("\n\t enter name of emp");
    scanf("%s",p->name);
    printf("\n\t enter salary of emp");
    scanf("%f",&p->salary);
    printf("\n\t enter id of emp");
    scanf("%d",&p->id);
    printf("\n\tname=%s \n\tsalary=%f \n\tid=%d",p->name,p->salary,p->id);
    }

    ReplyDelete
    Replies
    1. poonam pusavale11:58 AM

      /*display n,s,id using pointer to structure*/
      #include
      void main()
      {
      struct emp
      {
      char name[10];
      float salary;
      int id;
      }e;
      struct emp *p;
      p=&e;
      printf("\n\t enter name of emp");
      scanf("%s",p->name);
      printf("\n\t enter salary of emp");
      scanf("%f",&p->salary);
      printf("\n\t enter id of emp");
      scanf("%d",&p->id);
      printf("\n\tname=%s \n\tsalary=%f \n\tid=%d",p->name,p->salary,p->id);
      }

      Delete
  4. Dipali Kore12:23 PM

    /*To Display the name of book,pages and price using pointer to structure*/
    #include
    void main()
    {
    struct book
    {
    char name[10];
    float price ;
    int pages;
    }b;
    struct book *p;
    p=&b;
    printf("\n\t Enter name of Book");
    scanf("%s",p->name);
    printf("\n\tEnter price of Book");
    scanf("%f",&p->price);
    printf("\n\tEnter pages of Book");
    scanf("%d",&p->pages);
    printf("\n\tBook name=%s \n\tBook price=%f \n\tBook pages=%d",p->name,p->price,p->pages);
    }

    ReplyDelete
  5. Bhosale Dhanashri SE312:33 PM

    #include
    #include
    void main()
    {
    struct book
    {

    int pages;
    char name[10];
    float price;
    }b;
    struct book *p;
    p=&b;


    printf("\n\t Enter the pages of book==");
    scanf("%d",&p->pages);
    printf("\n\t Enter the name of book==");
    scanf("%s",p->name);
    printf("\n\t Enter the price of book==");
    scanf("%f",&p->price);

    printf("\n\t pages of book=%d ,name ofbook=%s,priceofbook =%f",p->pages,p->name,p->price);

    }






    ReplyDelete
  6. Bhanvase Yashoda10:55 AM

    /*pointer to structure of employee*/
    #include
    void main()
    {

    struct employee
    {

    char name[10];
    float salary;
    int id;
    int mno;
    }b;

    struct employee*p;
    p=&b;

    printf("\n\t enter name");
    scanf("%s",p->name);
    printf("\n\t enter salary" );
    scanf("%f",&p->salary);
    printf("\n\t enter id");
    scanf("%d",&p->id);
    printf("\n\t enter mno");
    scanf("%d",&p->mno);

    printf("name=%s,salary=%f,id=%d,mno=%d",p->name,p->salary,p->id,p->mno);









    }

    ReplyDelete
  7. sachita jadhav11:04 AM

    /* pointer to structure */
    #include
    void main()
    {
    struct book
    {
    char name[20];
    float price;
    int pages;
    }b;

    struct book *p1;
    p1=&b;
    printf("\n enter name of book");
    scanf("%s",p1->name);
    printf("\n enter price of book");
    scanf("%f",&p1->price);
    printf("\n enter pages of book" );
    scanf("%d",&p1->pages);
    printf("\n name of book=%s \n price of book=%f \n pages of book=%d ",p1->name,p1->price,p1->pages);
    }

    ReplyDelete
  8. mubin pirjade11:12 AM

    #include
    void main()
    {
    struct book
    {
    int pg;
    int price;
    char name[20];
    };
    struct book *ptr,p;
    ptr=&p; //referencing pointer to memory address

    printf("\n\tEnter the pages:");
    scanf("%d",&ptr->pg);
    //fflush(0);
    printf("\n\tEnter the price:");
    scanf("%d",&ptr->price);
    //fflush(0);
    printf("\n\tEnter name of book:");
    scanf("%s",&ptr->name);
    printf("\n\tBook details are:\n\t1.Name:%s \n\t2.Number of pages:%d \n\t3.price of book:%d ",ptr->name,ptr->pg,ptr->price);
    }

    ReplyDelete
  9. Awate Snehal12:06 PM

    /*Info of book*/
    #include
    void main()
    {
    struct book
    {
    char name[20];
    float price;
    int pages;
    }b;
    struct book *p;
    p=&b;
    printf("\n\t enter name of book");
    scanf("%s",p->name);
    printf("\n\t enter price of book");
    scanf("%f",&p->price);
    printf("\n\t enter pages of book");
    scanf("%d",&p->pages);

    printf("\n\t name=%s,price=%f,pages=%d",p->name,p->price,p->pages);
    }

    ReplyDelete
  10. sonali nagane11:19 AM

    /*To Display the name of book,pages and price using pointer to structure*/
    #include
    void main()
    {
    struct book
    {
    char name[10];
    float price ;
    int pages;
    }b;
    struct book *p;
    p=&b;
    printf("\n\t Enter name of Book");
    scanf("%s",p->name);
    printf("\n\tEnter price of Book");
    scanf("%f",&p->price);
    printf("\n\tEnter pages of Book");
    scanf("%d",&p->pages);
    printf("\n\tBook name=%s \n\tBook price=%f \n\tBook pages=%d",p->name,p->price,p->pages);
    }

    ReplyDelete

Post a Comment