NEW
Font size
WorksheetsInput And Output in C
Total questions: 10
Worksheet time: 9mins
A format specifier does what?
specifies the format of input or output
specifies the format of input only
specifies the format of output only
specifies the format of your hard drive
Which format specifier is often used to print integers?
%c
%d
%f
%x
Which of the following is a valid way to accept user input in the form of an integer value and store it in a variable named entry?
scanf(%d, &entry);
scanf("%s", &entry);
scanf("%d", &entry);
scanf(%s, &entry);
Assume we've used a float variable to store a price in dollars that we want to display in standard currency format (ex. $3.75). Which of the following uses printf() to correctly display that price?
printf("Price: $%d", price);
printf(Price: $%f, price);
printf("Price: $", %f, price);
printf("Price: $%f", price);
To print out a and b given below, which of the following printf() statement will you use?
#include<stdio.h>
float a=3.14;
double b=3.14;
printf("%f %lf", a, b);
printf("%Lf %f", a, b);
printf("%Lf %Lf", a, b);
printf("%f %Lf", a, b);
To scan a and b given below, which of the following scanf() statement will you use?
#include<stdio.h>
float a;
double b;
scanf("%f %f", &a, &b);
scanf("%Lf %Lf", &a, &b);
scanf("%f %Lf", &a, &b);
scanf("%f %lf", &a, &b);
What will be the output of the program if value 25 given to scanf()?
25
2.5
1
0
What will be the output of the program ?
%%
%
Error
%%%%
What will be the output of the program ?
3.15
3.00
3.2
3
Point out the error in the program?
Error: we may not get input for second scanf() statement
Error: suspicious char to in conversion in scanf()
None of above
No error
