Awesome q2a theme
0 votes
15 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) | 15 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. Mellophi

    97 Points

  2. Ashutosh07091999

    69 Points

  3. prakhar2810

    7 Points

  4. Kushagra गुप्ता

    7 Points

  5. srestha

    7 Points

  6. sdutta

    6 Points

  7. kuldeep kumar07

    6 Points

  8. toppoavinash

    6 Points

  9. Shoaib_Ahmed

    6 Points

  10. prashastinama

    6 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. Mellophi

    103 Points

  2. Ashutosh07091999

    72 Points

  3. Shaik Masthan

    13 Points

  4. srestha

    9 Points

  5. Unnayan kumar

    8 Points

  6. prakhar2810

    7 Points

  7. Sourav Kar

    7 Points

  8. anurag_yo

    7 Points

  9. Kushagra गुप्ता

    7 Points

  10. sdutta

    6 Points

7,710 questions
1,823 answers
11,131 comments
95,090 users