0% found this document useful (0 votes)
43 views

Daily Test#print 1

The document contains 100 multiple choice questions about the printf() function in C language. The questions cover various aspects of printf() such as format specifiers, escape sequences, field width, precision, padding, string formatting, integer formatting, floating point formatting etc. Detailed explanations are provided for each question.

Uploaded by

Vishal Hammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Daily Test#print 1

The document contains 100 multiple choice questions about the printf() function in C language. The questions cover various aspects of printf() such as format specifiers, escape sequences, field width, precision, padding, string formatting, integer formatting, floating point formatting etc. Detailed explanations are provided for each question.

Uploaded by

Vishal Hammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 15

Google Drive: 1.

CLanguage> printf >


Title: DailyTest#printf1
(25 questions three papers banana he)

Q: void main()
{
printf("AAA","BBB","CCC");
}

ANS:
AAA

Q: void main()
{
printf("AAA",10,20,'A',2.5);
}
ANS:
AAA

Q: void main()
{
printf(10,20);
}
Options:
10
20
10 20
Error
ANS: d

Q: void main()
{
char a[]="AAA",b[]="BBB",c[]="CCC";
printf(a);
}
ANS:
AAA

Q: void main()
{
char a[]="AAA",b[]="BBB",c[]="CCC";
printf(a,b,c);
}
ANS:
AAA

Q: void main()
{
char a[]="AAA";
printf(a,"BBB",10,20);
}
ANS:
AAA

Q: void main()
{
printf("%d %d %d %d",'\a','a','\b');
printf(" %d %d %d",'\t','\r','\n');
}
ans:
7 97 8 9 13 10

Q: void main()
{
printf("AAA\aBBB");
}
Options:
AAABBB (with beep sound)
AAA (with beep sound)
BBB (with beep sound)
AAA10BBB
ANS: a

Q: void main()
{
printf("ABC\b");
}
Options:
ABC (cursor is pointing after C)
ABC (cursor is pointing inside C)
ABC (cursor is pointing before C)
ABC (cursor is pointing A)
ans: b

Q: void main()
{
printf("ABC\bX");
}
ANS:
ABX

Q: void main()
{
printf("ABC\b\bX");
}
ANS:
AXC

Q12: void main()


{
printf("ABC\rX");
}
ANS:
XBC

Q: void main()
{
printf("ABC\rXYZ");
}
ANS:
XYZ

Q: void main()
{
printf("ABC\rX\bYZ");
}
ANS:
YZC
Q: void main()
{
printf("ABC%cX",8);
}
ans:
ABX

Q: void main()
{
printf("A%dB%dC",10,20,30);
}
ANS:
A10B20C

Q: void main()
{
printf("%d",10,20,30);
}
ANS:
10

Q: void main()
{
printf("%d %d",10,20,30);
}
ANS:
10 20

Q: void main()
{
printf("%d %d %d",10);
}
Options:
10
g g 10
1 g g
Error
ANS: c

Q: void main()
{
int x=10,y=20,z=30;
printf("%d %d %d");
}
ANS:
30 20 10

Q: void main()
{
printf("%d\b%d",10,20,30);
}
ANS:
120

Q: void main()
{
printf("%c %c %c",'A',65,(int)'A');
}
ANS:
A A A

Q: void main()
{
printf("%d %d %d",'A',65,(int)'A');
}
ANS:
65 65 65

Q: void main()
{
printf("%c",321);
}
ANS:
A

Q: void main()
{
unsigned int x=65535;
unsigned int y=-1;
printf("%u %u ",x,y);
printf("%d %d ",x,y);
printf("%X %x",x,y);
}
ANS: 65535 65535 -1 -1 FFFF ffff

Q: void main()
{
printf("%o %d %x",0100,100,0x100);
}
ANS:
100 100 100

Q: void main()
{
printf("%o %o %o",0100,100,0x100);
}
ANS:
100 144 400

Q: void main()
{
printf("%d %d %d",0100,100,0x100);
}
ANS:
64 100 256

Q: void main()
{
printf("%x %x %x",0100,100,0x100);
}
ANS:
40 64 100

Q: void main()
{
printf("%o %d %x",100,100,100);
}
ANS:
144 100 64

Q: void main()
{
printf("WELCOME"+3);
}
ANS:
COME

Q: void main()
{
printf(5+"ABCDE"-2);
}
ANS:
DE

Q: void main()
{
printf("ABCDE\0FGHIJ");
}
ANS:
ABCDE

Q: void main()
{
printf("ABCDE\0FGHIJ"+2);
}
ANS:
CDE

Q: void main()
{
printf("ABCDE\0FGHIJ"+7);
}
ANS:
GHIJ

Q: void main()
{
printf("%d"+1,10);
}
ans:
d

Q: void main()
{
printf("%d %d %d"+5,10,20,30);
}
ans:
10

Q: void main()
{
printf("%+d %d",10,20);
}
ans:
+10 20
Q: void main() //Fill space carefully
{
printf("S%5d%-5d%5dE",5,25,165);
}
ans:
S 525 165E

Q: void main() //Fill space carefully


{
printf("S%5dE",25);
}
ans:
S 25E

Q: void main() //Fill space carefully


{
printf("S%-5dE",25);
}
ans:
S25 E

Q: void main() //Fill space carefully


{
printf("S%+5dE",25);
}
ans:
S +25E

Q: void main() //Fill space carefully


{
printf("S%+05dE",25);
}
ans:
S+0025E

Q: void main()
{
printf("%o %d %x",100,100,100);
printf("%#o %#d %#x\n",100,100,100);
}
ans:
144 100 64

Q: void main()
{
printf("%#o %#d %#x",100,100,100);
}
ANS:
0144 100 0x64

Q: void main()
{
printf("%s %s"+3,"ABCDE"+2,"WELCOME"+3);
}
ans:
CDE

Q: void main()
{
printf("%e %f",2e3,2e3);
}
ans:
2.000000e+03 2000.000000

Q: void main()
{
printf("%e %f",2000.0,2000.0);
}
ans:
2.000000e+03 2000.000000

Q: void main()
{
printf("%d",2e3==2000.0);
}
ans:
1

Q: void main()
{
int x=printf("S%5dE",27);
printf("%d",x);
}
ans:
S 27E7

Q: void main()
{
printf("A%10f",25.71);
}
ans:
A 25.710000

Q: void main()
{
printf("A%+12f",25.71);
}
ans:
A +25.710000

Q: void main()
{
printf("A%+12fB",25.71);
}
ans:
A+25.710000 B

Q: void main()
{
printf("%.6f\n",25.7162539);
}
ans:
25.716254

Q: void main()
{
printf("%.5f\n",25.7162539);
}
ans:
25.71625

Q: void main()
{
printf("%.4f\n",25.7162539);
}
ans:
25.7163

Q: void main()
{
printf("%.3f\n",25.7162539);
}
ans:
25.716

Q: void main()
{
printf("%.2f\n",25.7162539);
}
ans:
25.72

Q: void main()
{
printf("%.1f\n",25.7162539);
}
ans:
25.7

Q: void main()
{
printf("%.0f\n",25.7162539);
}
ans:
26

Q: void main()
{
printf("A%10.6f\n",25.7162539);
printf("A%10.5f\n",25.7162539);
printf("A%10.4f\n",25.7162539);
printf("A%10.3f\n",25.7162539);
printf("A%10.2f\n",25.7162539);
printf("A%10.1f\n",25.7162539);
printf("A%10.0f\n",25.7162539);
}
Options:
Option1:
A 25.716254
A 25.71625
A 25.7163
A 25.716
A 25.72
A 25.7
A 26
Option2:
A25.716254
A25.71625
A25.7163
A25.716
A25.72
A25.7
A26

Option3:
A 25.716254
A 25.71625
A 25.7163
A 25.716
A 25.72
A 25.7
A 26

Option4:
None

ans:
Option1

Q:void main()
{
printf("A%-+10.6fB\n",25.7162539);
printf("A%-+10.5fB\n",25.7162539);
printf("A%-+10.4fB\n",25.7162539);
printf("A%-+10.3fB\n",-25.7162539);
printf("A%-+10.2fB\n",-25.7162539);
printf("A%-+10.1fB\n",-25.7162539);
printf("A%-+10.0fB\n",25.7162539);
}
Options:

Option1:
A+25.716254B
A +25.71625B
A +25.7163B
A -25.716B
A -25.72B
A -25.7B
A +26B

Option2:
A+25.716254B
A+25.71625 B
A+25.7163 B
A-25.716 B
A-25.72 B
A-25.7 B
A+26 B

Option3:
A +25.716254B
A +25.71625 B
A +25.7163 B
A -25.716 B
A -25.72 B
A -25.7 B
A +26 B

Option4:
None

ANS:
Option2

Q: void main()
{
int w=10,p=1;
printf("A%*.*f\n",10,6,25.7162539);
printf("A%*.*f\n",10,5,25.7162539);
printf("A%10.*f\n",4,25.7162539);
printf("A%*.3f\n",10,25.7162539);
printf("A%*.*f\n",w,p+1,25.7162539);
printf("A%*.*f\n",w,p,25.7162539);
printf("A%*.0f\n",w,25.7162539);
}
Options:
Option1:
A 25.716254
A 25.71625
A 25.7163
A 25.716
A 25.72
A 25.7
A 26

Option2:
A25.716254
A25.71625
A25.7163
A25.716
A25.72
A25.7
A26

Option3:
A 25.716254
A 25.71625
A 25.7163
A 25.716
A 25.72
A 25.7
A 26

Option4:
None

ans:
Option1

Q: void main()
{
int x=5;
printf("A%5d",253);
printf("A%*d",5,253);
printf("A%*d",x,253);
}
ans:
A 253A 253A 253

Q: void main()
{
printf("\n");
}
Options:
\n
n
No Output
ans:
c

Q: void main()
{
printf("\");
}
Options:
\
"
\"
Error
ans: d

Q: void main()
{
printf("\\");
}
Options:
\
"
\"
Error
ans: a

Q: void main()
{
printf("%%");
}
Options:
%
%%
Garbage
Error
ans:
a

Q: void main()
{
printf("\%");
}
Options:
%
%%
\%
Error
ans:
a

Q: void main()
{
printf("\\n");
}
Options:
\\n
\n
n
Error
ans: b

Q: void main()
{
printf(""Hello"");
}
Options:
Hello
"Hello"
Error
Garbage
ans:
c

Q: void main()
{
printf("\"Hello\"");
}
Options:
Hello
"Hello"
Error
Garbage
ans:
b

Q: void main()
{
printf("%c %d",'A','A');
printf("%c %d",65,65);
}
ans: A 65A 65

Q: void main()
{
printf("%c",'65');
}
ans: 6

Q: void main()
{
printf("%s","ABCD");
}
ans: ABCD
Q: void main()
{
printf("S%5sE","ABCD");
}
ans:
S ABCDE

Q: void main()
{
printf("S%4.1sE\n","ABCD");
printf("S%4.2sE\n","ABCD");
printf("S%4.3sE\n","ABCD");
printf("S%4.4sE\n","ABCD");
}
Options:
Option1
SA E
SAB E
SABC E
SABCDE

Option2:
S AE
S ABE
S ABCE
SABCDE

Option3:
SABCDE
S ABCE
S ABE
S AE

Option4:
SABCDE
SABC E
SAB E
SA E

ANS:
Option2

Q: void main()
{
printf("S%-4.1sE\n","ABCD");
printf("S%-4.2sE\n","ABCD");
printf("S%-4.3sE\n","ABCD");
printf("S%-4.4sE\n","ABCD");
}
Options:
Option1
SA E
SAB E
SABC E
SABCDE

Option2:
S AE
S ABE
S ABCE
SABCDE

Option3:
SABCDE
S ABCE
S ABE
S AE

Option4:
SABCDE
SABC E
SAB E
SA E

ans:
Option1

Q: How many white spaces are printed between two *.


void main()
{
printf("%-4.1s\b%4.1s\n","****","****");
}
Option:
2
3
4
5

ans:
d

Q: How many white spaces are printed between two *.


void main()
{
printf("%-4.3s\b%4.3s\n","****","****");
}
Option:
1
2
3
4
ans:
a

Q: void main()
{
int a=5,b,c=11;
printf("%d %d %d");
}
Option
5 11 garbage
garbage 11 5
5 garbage 11
11 5 garbage

ans:
d
Q: void main()
{
int a=5,b,c=11;
printf("%d %d %d");
b=1;
}
Option
11 garbage 5
5 garbage 11
5 1 11
11 5 garbage
ans:
a

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy