KEMBAR78
C Prog. - Structures | PDF
C Programming - Structures

Organized By: Vinay Arora
               Assistant Professor, CSED
               Thapar University, Patiala
Program - 1
  #include<stdio.h>                                   getch();
  #include<conio.h>                                    }
  void main()
   {
    char name[3];
    float price[3],i;
    clrscr();

   printf("Enter names, price of 3 booksn");

   for(i=0;i<=2;i++)
    scanf("n%c %f",&name[i],&price[i]);

   printf("nAnd this is what you have enteredn");
   for(i=0;i<=2;i++)
    printf("%c %fn",name[i],price[i]);

                                   Vinay Arora
                                      CSED
Program – 1 (output)




                Vinay Arora
                   CSED
Program - 2
  #include<stdio.h>                   printf("nAnd this is what you have enteredn");
  #include<conio.h>                   printf("n%c %f",b1.name,b1.price);
  void main()                         printf("n%c %f",b2.name,b2.price);
   {                                  printf("n%c %f",b3.name,b3.price);
    struct book
     {                                getch();
      char name;                     }
      float price;
     };
    struct book b1,b2,b3;
    clrscr();

   printf("Enter names, price of 3 booksn");
   scanf("n%c %f",&b1.name,&b1.price);
   scanf("n%c %f",&b2.name,&b2.price);
   scanf("n%c %f",&b3.name,&b3.price);

                                      Vinay Arora
                                         CSED
Program – 2 (output)




                Vinay Arora
                   CSED
Thnx…



  Vinay Arora
     CSED

C Prog. - Structures

  • 1.
    C Programming -Structures Organized By: Vinay Arora Assistant Professor, CSED Thapar University, Patiala
  • 2.
    Program - 1 #include<stdio.h> getch(); #include<conio.h> } void main() { char name[3]; float price[3],i; clrscr(); printf("Enter names, price of 3 booksn"); for(i=0;i<=2;i++) scanf("n%c %f",&name[i],&price[i]); printf("nAnd this is what you have enteredn"); for(i=0;i<=2;i++) printf("%c %fn",name[i],price[i]); Vinay Arora CSED
  • 3.
    Program – 1(output) Vinay Arora CSED
  • 4.
    Program - 2 #include<stdio.h> printf("nAnd this is what you have enteredn"); #include<conio.h> printf("n%c %f",b1.name,b1.price); void main() printf("n%c %f",b2.name,b2.price); { printf("n%c %f",b3.name,b3.price); struct book { getch(); char name; } float price; }; struct book b1,b2,b3; clrscr(); printf("Enter names, price of 3 booksn"); scanf("n%c %f",&b1.name,&b1.price); scanf("n%c %f",&b2.name,&b2.price); scanf("n%c %f",&b3.name,&b3.price); Vinay Arora CSED
  • 5.
    Program – 2(output) Vinay Arora CSED
  • 6.
    Thnx… VinayArora CSED