20120113

How to use structures in C language

//========================
//Program in C to learn structures in C, struct3.c
//========================

//Without structure we can store and display the details of book, collection of hetrogeneous data
//But this way we are declaring array of each data type used like char,int,float array etc
//so better way would be to declare a single array of books rather than array of all data types used
// for above details see the program struct4.c
#include<stdio.h>
int main()
{
        char title[3];
        int page[3];
        float price[3];
        int i;
        printf("\n Enter the title, page and price for the 3 books \n");
        for(i=0;i<3;i++)
                scanf("%c  %d  %f",&title[i],&page[i],&price[i]);
        printf("\n You entered: \n");
        for(i=0;i<3;i++)
                printf("%c %d %f",title[i],page[i],price[i]);

return 0;
}


Previous                             Home                               Next

2 comments:

  1. Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C

    ReplyDelete
  2. Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C
    Program for structure in C++/CPP/C

    ReplyDelete