C Programming - Input / Output

11.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    int a=250;
    printf("%1d\n", a);
    return 0;
}
1250
2
50
250
Answer: Option
Explanation:

int a=250; The variable a is declared as an integer type and initialized to value 250.

printf("%1d\n", a); It prints the value of variable a.

Hence the output of the program is 250.


12.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    FILE *fp;
    char ch, str[7];
    fp=fopen("try.c", "r"); /* file 'try.c' contains "This is Nagpur" */
    fseek(fp, 9L, SEEK_CUR);
    fgets(str, 5, fp);
    puts(str);
    return 0;
}
agpur
gpur
Nagp
agpu
Answer: Option
Explanation:
No answer description is available. Let's discuss.

13.
What will be the output of the program if value 25 given to scanf()?
#include<stdio.h>

int main()
{
    int i;
    printf("%d\n", scanf("%d", &i));
    return 0;
}
25
2
1
5
Answer: Option
Explanation:

The scanf function returns the number of input is given.

printf("%d\n", scanf("%d", &i)); The scanf function returns the value 1(one).

Therefore, the output of the program is '1'.