int i;
i=2;
i++;
if(i=4)
{
printf(i=4);
}
else
{
printf(i=3);
}
output of the program ?

Answers were Sorted based on User's Feedback



int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / asit mahato

The conditional test if(i=4) is true for evrey non zero
value of i.As here i=3 here execute the if statement.But
printf can't print nothing because we have not mation the
proper syntax of printf.if we replace
printf(i=4)by printf("i=4")
it will give the following output:
i=4

Is This Answer Correct ?    15 Yes 1 No

int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / akbar shan

There Wont be any output for this program.It will show
error.Because 1:inside if "=" is used.2:"printf" cant print
the value

Is This Answer Correct ?    13 Yes 3 No

int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / sathish

output is 3

Is This Answer Correct ?    7 Yes 5 No

int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / jignesh patel

output of this program is 3

Is This Answer Correct ?    8 Yes 6 No

int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / stuti

This program will give error. Becoz the format of if
statement and printf statement- both are wrong.
In if, instead of if(i==4), if(i=4) is written and in
printf statement, there should be printf("i==4"); and printf
("i=3");
So it will not be compiled.

Is This Answer Correct ?    4 Yes 2 No

int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / raj

hi
frinds they are not compare with i it is error

Is This Answer Correct ?    1 Yes 0 No

int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / manishsoni

it show errors,bcoz
in c language,to print anyone we want to enclose that in " ".
so both the printf statement are wrong,so it is not show
proper result.
To show proper result we show that program and describe line
to line....

#include<stdio.h>
#include<conio.h>
int main()
{
int i;
i=2;
i++;
if(i=4)
{
printf("4");
}
else
{
printf("3");
}
getch();
}

In this prg i is declare as int type,after that 2 is store
into the i after i increased by not store so there is no
affect of the i's value.
at if statement
if(i=4)
here 4 is assigned into the i variable so
if statement is look like as;
if(4)which is treat is as ;
the if statement is thought that any non zero value is true
so if statement is true..
and execute first printf statement so the value is
printf("i=4");
so the final answer or result is:
i=4;

Is This Answer Correct ?    1 Yes 0 No

int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / ssssssssss

output
3

Is This Answer Correct ?    5 Yes 5 No

int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / ruchi

outout will be 4 in case code is printf("i=4");
printf("i=3");
else this program will show two error

Is This Answer Correct ?    4 Yes 4 No

int i; i=2; i++; if(i=4) { printf(i=4); } else { ..

Answer / asdf

un predictable

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]

7 Answers  


How can we open a file in Binary mode and Text mode?what is the difference?

1 Answers   PanTerra,


Write a program to reverse a linked list in c.

0 Answers   DELL, HAL,


How to convert decimal to binary in C using recursion??

4 Answers   HP, IBM,


What is assignment operator?

0 Answers  


What is c basic?

0 Answers  


what is the difference between entry control and exit control statement?

12 Answers   Darbari Lal DAV Model School,


i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me

0 Answers   Microsoft,


what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }

4 Answers  


explain about storage of union elements.

2 Answers   ABC, Bosch,


what is the flow of execution in cprogram? ex:printf();,scanf();

2 Answers  


pointer_variable=(typecasting datatype*)malloc(sizeof(datatype)); This is the syntax for malloc?Please explain this,how it work with an example?

2 Answers   eClerx, Excel, kenexa,


Categories