Awesome q2a theme
0 votes
17 views
#include<stdio.h>
void fun(int a, int b, int c){
printf("%d\n%d\n%d",a,b,c);
}
int main(){
int i,n=-1;
fun(i=2,i>n,(i==2)?1:0);
return 0;
}

According to me, answer should be:-

2

1

1.

But when I run it, it is coming out to be

2

1

0

closed with the note: undefined behaviour in C... out of gate
in Programming by (8 points)
closed by | 17 views
0
order of evaluation of function arguments are undefined in C.

initially i have garbage value.

so, i=2 may execute after (i==2)?1:0
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
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Jul 2020
  1. Shaik Masthan

    39 Points

  2. hiteshpujari

    9 Points

  3. Venkatesh Akhouri

    6 Points

  4. Meghana518

    6 Points

  5. bittujash

    6 Points

  6. Pawan_k

    6 Points

  7. rits78671

    6 Points

  8. srestha

    6 Points

  9. RavGopal

    4 Points

  10. Sumaiyas

    4 Points

7,543 questions
1,783 answers
10,867 comments
90,482 users