C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - Find Output of Program (Q.No. 5)
5.
What will be the output of the program ?
#include<stdio.h>
int main()
{
enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);
return 0;
}
Discussion:
31 comments Page 3 of 4.
Agana said:
1 decade ago
enum takes the size of int values.
Sudha said:
1 decade ago
I agree all the points for my friends!
Union stores in memory in same data type in same place. But continue memory allocation.
Union stores in memory in same data type in same place. But continue memory allocation.
Puneet said:
1 decade ago
Enum stand for?
Akanksha said:
1 decade ago
Enum is short form use for Enumerated data type definition. Correct me if I m wrong.
Ramkesh said:
8 years ago
Nice Explanation, Thank You @Ramdas.
Manoja V. said:
8 years ago
Thank you @Karthika.
Karth said:
8 years ago
Yes, I agree with your concept @Karthika.
Kamal said:
7 years ago
Yes, I agree @Karthika and @Akansha.
Keerthana said:
7 years ago
By default, enum assign 0 as the starting value and successive values will be assigned for remaining members. i.e. 0 for MON, 1 for TUE, 2 for WED and so on. But if member is pre-assigned, its successive value will be assigned for next member if it is not assigned with any value. If the next member is assigned with some value then it will be considered. So in above eg, MON=-1, TUE=-1+1=0, WED=6, THU=6+1=7, FRI=7+1=8, SAT=8+1=9.
Hence the output:-1, 0, 6, 7, 8, 9.
Hence the output:-1, 0, 6, 7, 8, 9.
(10)
Murthy said:
7 years ago
It's clear to understand, Thanks @Karthika.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers