Pages1

C Programing: Practice questions on computing fundamentals

Interview/practice questions on c computing fundamentals.
Magic of formatting specifier with printf.

1. How printf will tackle a number when printed with %c?

#include<stdio.h>
int main()
{
    printf("%c\n", 51);
}

2. How printf behaves when with %d format specifier?

#include<stdio.h>
int main()
{
    printf("%d\n", '1');
}

 3. What will be printed by the following program?
#include<stdio.h>
int main()
{
    printf("%d\n", '2' - '1');
}

4. What will be printed by the following program:
#include<stdio.h>
int main()
{
    printf("%c\n", '1' + 1);
}

5. How printf behaves with  %x format specifier?
#include<stdio.h>
int main()
{
    printf("%x\n", '1' + 1);
}

For answers Click here

No comments:

Post a Comment