C Puzzle #11


Yesterday i was reading about  comma operator from yashvant kanetkar book. When i went through this program, it appeared 100 % correct. But i was wrong :(.
#include <stdio.h>

int main()
{
        int a = 1,2;
        printf("a : %d\n",a);
        return 0;
}

If you think you really know c programming. Then i want to challenge you. Can you tell the output of this program givenn below. Also tell me is it valid or invalid.
#include <stdio.h>
int main()
{
        int i=45;
        printf("%d\n",printf("%d",printf("%d",i)));
        return 0;
}

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Small correction in Q1: int a = (1,2); instead of ::int a = 1,2; Assignment happens from right.

    Q2: Printf function returns string count.

    ReplyDelete

Your answer for the question

Related Posts Plugin for WordPress, Blogger...