Operators and Expressions in C

Status
Not open for further replies.

HarshJain

Newbie
Joined
Jul 11, 2022
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
India
Visit site
Activity points
35
Hello Everyone, I am confused with the code can somebody tell me What is the output of the following program?

Code:
#include <stdio.h>
 
int main()
{
   int a = 1;
   int b = 1;
   int c = a || --b;
   int d = a-- && --b;
   printf("a = %d, b = %d, c = %d, d = %d", a, b, c, d);
   return 0;
}

Can someone help me with this?

Thanks in Advance!!
 

Use an online simulator :




Regards, Dana.
 
try this code and you will find the point:

int a = 1;
int b = 1;
printf("a = %d, b = %d \n",a,b);
int c = a || --b;
printf("a = %d, b = %d, c =%d \n",a,b,c);
int d = a-- && --b;
printf("a = %d, b = %d, c = %d, d = %d",a,b,c,d);
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…