main()
{
int a=0;
if(a=0) printf("Ramco Systems\n");
printf("India\n");
}
output?

Answers were Sorted based on User's Feedback



main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); ..

Answer / fazlur rahaman naik

actually the output will b : India only.
the above programme doesn't produce any error at if(a =
0).because we r assiging value here, we r not comparing the
value here.so the condition will fail here and the next
statement after if condition will print.

Is This Answer Correct ?    10 Yes 0 No

main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); ..

Answer / vikesh

the answer will be India
if statement executes the statement if it is true i.e other
than "0"..[eg.if(1)]
here we are giving a=0 which implies false.
so the if statement doesnot execute first statement.
if you dont agree check following
main()
{
int a=0;
if(a=1)/*other than zero any number*/
printf("Ramco Systems\n")
printf("India\n");}

Is This Answer Correct ?    8 Yes 1 No

main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); ..

Answer / shivangi

only india will be printed ...........

Is This Answer Correct ?    4 Yes 1 No

main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); ..

Answer / kushalava

India only

Is This Answer Correct ?    3 Yes 0 No

main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); ..

Answer / ripal

The output will produce error because there is error at if
(a=0).It should be if(a==0)

Is This Answer Correct ?    8 Yes 7 No

main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); ..

Answer / yogendra jain

Ramco Systems
India

Is This Answer Correct ?    3 Yes 6 No

main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); ..

Answer / vikramanj

Actually compile time err wil occur..
Its "Possibly incorrect assignment"
Its due to if(a=0)??
Its wrong,we have to compare only while checking
conditions..
we have to use the operators which are used to check
conditions like ==,<=,>=....

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More C Interview Questions

int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+zap(n-1); } then the call zap(6) gives the values of zap [a] 8 [b] 9 [c] 6 [d] 12 [e] 15

10 Answers   Wipro,


Is there any demerits of using pointer?

0 Answers  


Which is best book for data structures in c?

0 Answers  


Program to swap the any two elements in an array containing N number of elements?

1 Answers   Bosch, Glenwood, Ugam Solutions,


what is c language?

2 Answers  






what is differnence b/w macro & functions

1 Answers  


How many ways are there to swap two numbers without using temporary variable? Give the each logic.

9 Answers  


What is a macro?

0 Answers  


how to find out the inorder successor of a node in a tree??

2 Answers   TCS, Yahoo,


What is wrong in this statement? scanf(“%d”,whatnumber);

0 Answers  


What is c programming structure?

0 Answers  


read a number & print all its devisors using c-program?

3 Answers  


Categories