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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If you know then define #pragma?

670


What is an lvalue?

627


Are the variables argc and argv are local to main?

780


Explain how can I read and write comma-delimited text?

646


how do you programme Carrier Sense Multiple Access

1510






What is a constant and types of constants in c?

596


What are the 4 types of organizational structures?

617


What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

723


What is the scope of local variable in c?

568


What are the advantages and disadvantages of c language?

552


What does sizeof function do?

608


Is it valid to address one element beyond the end of an array?

668


What is the difference between void main and main in c?

618


Write the Program to reverse a string using pointers.

610


How can you draw circles in C?

616