II-284 Programming Concepts
Additional Questions
What are the outputs of the following programs?
Programs on declaration and initialization of structures
1. Program to display information of a student
#include <stdio.h>
#include<conio.h>
void main()
{
struct emp
{
char name[30];
int age;
int sal ;
};
struct emp e={"Satish",28,20000};
clrscr();
printf("
Name : %s",e.name);
printf("
Age : %d",e.age);
printf("
Salary : %d",e.sal);
getche();
}
OUTPUT:
Name : Satish
Age : 28
Salary : 20000
2. Program to display time
#include <stdio.h>
#include <conio.h>
void main()
{ struct time
{
int second;
int minute;
int hour;
} t;
M13_ITL-ESL4791_02_SE_C13.indd 284 12/22/2012 5:06:16 PM