1) What is an Escape Sequence in C language.?
A) An escape sequence is a combination of two characters starting with Back Slash always.
B) An escape sequence is usually part of a string to tell compiler to produce New Lines, New tabs, Single or Double quotes etc
C) An escape sequence is used to format the output to look in desired way.
Explanation:
eg. \n outputs new line. \t outputs tab i.e 4 or 8 white spaces.
2) Choose a correct statement about C Escape Sequences.
A) \n produces new line.
B) \t produces one tab space (white spaces)
C) \b produces one Backspace
3) Choose a correct statement about C Escape Sequences.
A) \r produces one Carriage Return. \r does not take you to the next line. It takes cursor to only the beginning of same line.
C) \a produces Alert Sound or Beep Sound from PC motherboard speaker
4) Choose a correct statement about C Escape Sequences.
A) \' outputs one Single Quote. Right Single Quote.
B) \" outputs one Double Quote.
C) \\ produces one Visible Back Slash \.
5) What is a format specifier in C language.?
A) A format Specifier tells compiler to treat a variable value is predefined way.
B) Different format specifiers are used to print different type of data.
C) Format specifiers are used to write data to files in a formatted way.
6) Choose a valid C format specifier.?
A) %d prints integer constants
B) %u prints unsigned integer constants
C) %ld prints signed long and %lu prints unsigned long constants
7) Choose a correct statement about C format Specifiers.
A) %c prints unsigned or signed character constants.
B) %s prints string constants
C) %l or %L prints long constants.
8) Choose a correct statement about format specifiers.
A) %f prints float constants with 6 digits of precision
B) %lf prints double constants
C) %Lf prints long double constants
9) What does C format specifier %W.D represent.?
A) W represents total number of columns including precision digits.
B) D represents number of precision digits out of W columns.
C) Plus(+) before W.D is for Right Alignment. Minus(-) before W.D is for Left Alignment
10) Choose a C Formatted Input Output function below.
A) printf(), scanf()
11) Choose a C unformatted input output function below.
A) gets(), puts()
12) What is the output of C program.?
int main()
{
int a=123;
printf("*%06d*",a);
return 0;
}
A) *123*
Explanation:
%6d reservers 6 columns. %Zero6d causes Remaining columns will be filled with Zero.
13) What is the output of C program.?
int main()
{
int a=123456;
printf("*%03d*",a);
return 0;
}
A) *123*
Explanation:
%3d reserves three columns. But 123456 is more than 3 columns. So width 3 will be ignored.
14) What is the output of C program.?
int main()
{
int a=6543;
printf("*%5d,*%-5d*",a,a);
return 0;
}
Explanation:
%5d reserves 5 columns. 6543 is aligned right. So One Space is filled in the first column. %-5d aligns 6543 left. So right side one Space is filled as 6543 is only a 4 digit number.
15) What is the output of C program.?
int main()
{
float a=654.123456f;
printf("%3.3f,%3.2f",a,a);
return 0;
}
A) 654,654
Explanation:
%3.3 reserves 3 columns. But the 654.123456 is a 9 column number. So only .3 will be treated as important to print 3 digit precision number. .2 prints number with 2 digit precision.
16) What is the output of C program.?
int main()
{
char str[]="123";
printf("*%4s*%-4s*",str,str);
return 0;
}
A) *4123*4123*
Explanation:
%4s reserves 4 columns. If the string length is less you can see spaces on the left side. %-4s also reserves 4 columns but aligns content on the right side.
17) Choose a correct statement about sprintf and sscanf functions.?
char str[20];
A) sprintf(str,"formatstring",variables) prints output to console. sscanf(str,"formatstring",&variables) scans keyboard input and copies to str.
B) sprintf(str,"formatstring",variables) prints output to string str. sscanf(str,"formatstring",&variables) scans keyboard input and prints to console
C) sprintf(str,"formatstring",variables) prints output to string str. sscanf(str,"formatstring",&variables) scans input from str itself and assigns data to &variables.
Explanation:
Both functions SSCANF or SPRINTF avoid getting input from keyboard or displaying on Console / Screen.
18) What is the output of C program.?
int main()
{
char ch='A';
ch=getchar();
putchar(ch);
return 0;
}//input= S
A) A
Explanation:
getchar() reads one character from keyboard. putchar(ch) prints one character.
19) Choose a correct C statement.?
A) SCANF can accept all types of data from keyboard including numbers and strings
B) GETS can accept only one String of any length and any number of words. GETCHAR can accept only one character constant from keyboard.
C) SCANF can accept only single word Strings
20) What is the output of c program with %* operator.?
int main()
{
char kh;
scanf("%*c %c",&kh);
putchar(kh);
return 0;
}//input=G H
A) G
Explanation:
%* ignores the entered argument. So here G is ignored. 2nd argument, H is accepted by variable kh. Remember, You have to enter all arguments corresponding to each % symbol.