Programs to understand the basic data types and I/O in C.


Author : ITVoyagers (

Date :25th December 2018

Description : Programs to understand the basic data types and I/O.

void main()
    int i;
    char c;
    float f;
    double d;
    char s[10]; //string

/********* Printing size of Datatypes **********/

    printf("size of number: %d n",sizeof(int));
    printf("size of character: %d n",sizeof(char));
    printf("size of float: %d n",sizeof(float));
    printf("size of double: %d n",sizeof(double));
    printf("size of string for this program: %d nn",sizeof(s));

/******** Accepting values from user *********/

    printf("Enter a number: ");
    printf("Enter a character: ");
    scanf(" %c",&c);
    printf("Enter a float: ");
    printf("Enter a double: ");
    printf("Enter a string: ");

/******** Printing Accepted values *********/

    printf("nEntered number: %dn",i);
    printf("Entered character: %cn",c);
    printf("Entered float: %fn",f);
    printf("Entered double: %lfn",d);
    printf("Entered string: %s",s);


size of number: 4
size of character: 1
size of float: 4
size of double: 8
size of string for this program: 10

Enter a number: 5
Enter a character: v
Enter a float: 6.8
Enter a double: 6.655
Enter a string: ITVoyagers

Entered number: 5
Entered character: v
Entered float: 6.800000
Entered double: 6.655000
Entered string: ITVoyagers

Leave a Comment