Q:

C program to create, declare and initialize structure

0

C program to create, declare and initialize structure

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

in this program, we will learn how to declare a structure with different types of variables, declare and initialization of structure variable? Here we are not reading values from keyboard; we are assigning the values to the structure members at the time of structure variable declaration.

#include <stdio.h>

/*structure declaration*/
struct employee{
	char name[30];
	int empId;
	float salary;
};

int main()
{
	/*declare and initialization of structure variable*/
	struct employee emp={"Mike",1120,76909.00f};
	
	printf("\n Name: %s"	,emp.name);
	printf("\n Id: %d"		,emp.empId);
	printf("\n Salary: %f\n",emp.salary);
	return 0;
}

Output

 Name: Mike 
 Id: 1120 
 Salary: 76909.000000

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now