C Programming - Strings - Discussion
Discussion Forum : Strings - Find Output of Program (Q.No. 7)
7.
What will be the output of the program ?
#include<stdio.h>
int main()
{
printf("India", "BIX\n");
return 0;
}
Answer: Option
Explanation:
printf("India", "BIX\n"); It prints "India". Because ,(comma) operator has Left to Right associativity. After printing "India", the statement got terminated.
Discussion:
18 comments Page 2 of 2.
Ayush said:
9 years ago
In the case of printf statement once comma is read then it will consider preceding things as variable or values for format specifier.
Chakalamahesh said:
1 decade ago
Is comma operator left to right associativity or right to left associativity. Kindly tell me I am confusing in that.
Rajdeep said:
6 years ago
Comma operator always returns the right most value so the output of this question should be Bix.
Shubham said:
8 years ago
I got error on linux 64 bit compiler, it say's "too many arguments".
Can anyone help me?
Can anyone help me?
Suryakant sharma said:
1 decade ago
So this answer is not correct because comma oprerator have assosiativity right to left.
Rajnish said:
1 decade ago
Associativity of comma operator is right to left.
So the answer should be BIX.
So the answer should be BIX.
$tRiKeR said:
1 decade ago
It should be "BIX" as output not "India".
Nitin said:
7 years ago
No, we can't pass two strings in printf.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers