C Programming :: Input / Output

NA
SHSTTON
8
Solv. Corr.
31
Solv. In. Corr.
39
Attempted
0 M:0 S
Avg. Time

1 / 6

Choose the correct option.

fputs function is used to


AWrite characters to a file

BTakes 2 parameters

CReturns a character

DRequires a file pointer

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
21
Solv. Corr.
11
Solv. In. Corr.
32
Attempted
0 M:0 S
Avg. Time

2 / 6

Choose the correct option.

The function fprintf is used in a program


Awhen too many printf calls have been already used in the program

Bin place of printf, since printf uses more memory

Cwhen the output is to be printed on to a file

Dwhen the type of the variables to be printed are not known apriori

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
15
Solv. Corr.
17
Solv. In. Corr.
32
Attempted
0 M:0 S
Avg. Time

3 / 6

What is the following C Program doing?
#include <stdio.h>
void main ()
{
 char line [80];
 gets (line);
 puts (line);
}

Aprints horizontal straight lines on screens

Bprints 80 vertical lines on screen

Creads in a line of 80 characters

Dreads and prints lines composed of characters

Answer: Option D

Explanation:

In line 3, we are declaring a character array 'line' of exactly 80 bytes. In the next line, 'gets' is used to read a line of text from standard input device(stdin), and in the next line 'puts' is used to print the string or line of text. So the coreect option is D.   

Workspace

NA
SHSTTON
17
Solv. Corr.
14
Solv. In. Corr.
31
Attempted
0 M:0 S
Avg. Time

4 / 6

Choose the correct option.

if i,j,k are integers, the scanf function to enter i,j,k such that i is decimal,j is octal and k is hexadecimal would be


Ascanf("%x %x %8x",i,j,k)

Bscanf("%d %o %x", i,j,k)

Cscanf("%d %o %x",&i, &j, &k)

Dscanf("%d %8d %16d", &i, &j, &k)

Answer: Option C

Explanation:

Following are the format specifiers for the above cases-

1. %d- to scan an integer value.

2. %o- to scan an octal value.

3. %x- to scan value in hexadecimal format.

 

Workspace

NA
SHSTTON
13
Solv. Corr.
20
Solv. In. Corr.
33
Attempted
0 M:0 S
Avg. Time

5 / 6

What would be the output of the following C program if input to the program is 'e'?
#include <stdio.h>
void main ()
{
char lower, upper; 
lower = getchar(); 
upper= toupper (lower);
putchar (upper);
}

A53

Be

CE

DNothing

Answer: Option C

Explanation:

As lower=getchar(), and the input is 'e', so lower will contain 'e'. In the next line 'e' will get converted to its upper case i.e, upper will contain 'E'. In the next line 'E' will get printed, so the correct option is option C.

Workspace

NA
SHSTTON
17
Solv. Corr.
12
Solv. In. Corr.
29
Attempted
0 M:0 S
Avg. Time

6 / 6

choose the correct answer

float x, y, z;
scanf ("%f %f", &x, &y);

If input stream contains "4.2 3 2.3 ..."
What will x and y contain after scanf?


A4.2, 3.0

B4.2, 2.3

C4.2 2.0

DNone of the above

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace