Awesome q2a theme
0 votes
14 views
#include<stdio.h>
main()
{
enum boolean {true, false};
enum boolean a, b, c;
a = b=true;
c=(a==b);
if (c ==a)
 printf("TRUE");
else
printf ("FALSE");
}

 

what will be the output of above program & why?
in Programming by (9 points) | 14 views
+1

enum boolean {true, false};

those are not real boolean values. They just named as boolean variables and states are true, false.

By enum property, true=0, false=1. ( these are states of enum variable boolean only )

when a==b compared, it's true, so it returns 1 ( note that these are real boolean ), due to this c=1 but we have a=0

 

for more information https://www.geeksforgeeks.org/enumeration-enum-c/

1 Answer

0 votes
ANSWER:FALSE

EXAPLANATION:

#include<stdio.h>
main()
{
enum boolean {true, false};//true=0,false=1
enum boolean a, b, c;//a=0,b=1,c=2
a =( b=true);//right to left associativity// b=0,a=0
c=(a==b);//c=1 since a==b evaluates to true
if (c ==a)//since c=1and a=0 //evaluates to false
 printf("TRUE");
else
printf ("FALSE");//printed :-FALSE

}
by (112 points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users 2020 Aug 03 - 09
  1. Ashutosh07091999

    18 Points

  2. Mellophi

    13 Points

  3. prashastinama

    6 Points

  4. manas_kulkarni

    4 Points

  5. srestha

    2 Points

  6. Unnayan kumar

    1 Points

  7. aryashah2k

    1 Points

  8. Jhaiyam

    1 Points

  9. prabhat0987

    1 Points

  10. Kushagra गुप्ता

    1 Points

Weekly Top User (excluding moderators) will get free access to GATE Overflow Test Series for GATE 2021
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Aug 2020
  1. Ashutosh07091999

    21 Points

  2. Mellophi

    19 Points

  3. Unnayan kumar

    8 Points

  4. Sourav Kar

    7 Points

  5. anurag_yo

    7 Points

  6. Shaik Masthan

    7 Points

  7. prashastinama

    6 Points

  8. sureshthiyam

    6 Points

  9. manas_kulkarni

    6 Points

  10. srestha

    4 Points

7,688 questions
1,815 answers
11,053 comments
95,077 users