Feb 17, 2022

Structures in C language

struct keyword-use and operations

 #include <stdio.h>
struct busi_biscuit
{
    char* type;
    int min_price_rs;
    int gm_wgt;
};

int main()
{
    // creating struct of given type
    struct busi_biscuit parle_G;
    // creating struct of given type
    struct busi_biscuit Jim_jam;

    //assigning values to it
    parle_G.type = "Non-creamy";
    parle_G.min_price_rs = 5;
    parle_G.gm_wgt = 50;

    Jim_jam.type = "creamy";
    Jim_jam.min_price_rs = 25;
    Jim_jam.gm_wgt = 150;

    printf("Jim_jam(type): %s\n" , Jim_jam.type);
    printf("Jim_jam.minimum price(Rs) : %d Rs\n" , Jim_jam.min_price_rs);
    printf("Jim_jam Weight(gm) : %d gm \n" , Jim_jam.gm_wgt);

    return 0;
}

No comments:

Post a Comment

Comparing two files in C language.

Operations on More than one File.    # include < stdio.h > # include < stdlib.h > # include < string.h > int main ( int ...