C program to initializing structure variables directly and accessing them

 // initializing structure varibles directly and accessing them

#include <stdio.h>

struct emp

{

    int eno;

    char ename[20];

    float sal;

};

int main()

{

    struct emp e = {1001,"Rajni", 50000}; /*assign values in the same order in which variables are declared*/

    printf("Employee details:\n ");  

    printf("E.No: %d\n EName: %s\n Salary: %f\n",e.eno,e.ename,e.sal);

    

    return 0;

}

OUTPUT:

Comments

Popular posts from this blog

C Program to convert decimal to binary and find consecutive 1s in a binary number: