EmbLogic's Blog

what’s going on here????printing x=1 and y=1

#include<stdio.h>
int main()
{
int x=1,y=1,z;
if(y<0) if(y>0) x=3;
else x=5;
printf(“%d\n”,x);
printf(“%d\n”,y);
return 0;

2 Responses to what’s going on here????printing x=1 and y=1

  1. sheetal sharma says:

    there is nested if first if is false as y=1 so it does not execute second if and print value of x and y i.e 1

  2. it is like a whole if and else within a single if
    pictorially:
    if(condition)
    {
    if(condition)
    execute;
    else
    execute;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>