wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SASI -1st year -DAY6-AN (23.12.23)

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.
Which function is used to concatenate two strings in C?
a)
strcat()
b)
concat()
c)
strjoin()
d)
stringconcat()
2.
#include <stdio.h> int main() { char str1[] = "Hello"; char str2[] = "World"; strcat(str1, str2); printf("%s", str1); return 0; }
a)
"HelloWorld"
b)
"WorldHello"
c)
"Hello"
d)
"World"
3.
Which library must be included to use string functions in C
a)
<stdlib.h>
b)
<string.h>
c)
<math.h>
d)
<stdio.h>
4.
#include <stdio.h> int main() { char str[] = "C Language"; printf("%s", str + 2); return 0; }
a)
Prints "Language"
b)
Prints "C Language"
c)
Causes a compilation error
d)
Results in a runtime error
5.
#include <stdio.h> int main() { char str[] = "Hello"; str[0] = 'J'; printf("%s", str); return 0; }
a)
"Hello"
b)
"Jello"
c)
"H"
d)
Causes a compilation error
6.
#include <stdio.h> int main() { char str1[] = "Hello"; char str2[] = "Hello"; int result = strcmp(str1, str2); printf("%d", result); return 0; }
a)
Prints 0
b)
Prints 1
c)
Prints -1
d)
Causes a compilation error
7.
#include <stdio.h> int main() { char str[] = "Hello"; printf("%c", str[strlen(str) - 1]); return 0; }
a)
'o'
b)
H'
c)
l'
d)
e'
8.
#include <stdio.h> int main() { char str[] = "Hello"; printf("%d", str[0]); return 0; }
a)
Prints 'H'
b)
Prints 72
c)
Causes a compilation error
d)
Results in a runtime error
9.
#include <stdio.h> int main() { char str[] = "Programming"; printf("%s", str + 5); return 0; }
a)
"Programming"
b)
"amming"
c)
"ramming"
d)
"ammingming"
10.
#include <stdio.h> #include <string.h> int main() { char str1[] = "Hello"; char str2[] = "Hello"; int result = strncmp(str1, str2, 3); printf("%d", result); return 0; }
a)
Prints 0
b)
Prints 1
c)
Prints -1
d)
Causes a compilation error
11.
#include <stdio.h> int main() { char str[] = "Friday"; str[3] = '\0'; printf("%s", str); return 0; }
a)
"Friday"
b)
"Fri"
c)
"Frid"
d)
Causes a compilation error
12.
#include <stdio.h> int main() { char str[] = "C Programming"; printf("%d", str[4]); return 0; }
a)
Prints 'o'
b)
Prints 111
c)
Causes a compilation error
d)
Results in a runtime error
13.
#include <stdio.h> #include <string.h> int main() { char str1[] = "Good"; char str2[] = "Morning"; strncat(str1, str2, 3); printf("%s", str1); return 0; }
a)
Prints "Morning"
b)
Prints "GoodMorning"
c)
Prints "GoodMor"
d)
Results in a runtime error
14.
#include <stdio.h> int main() { char str[] = "C Programming"; printf("%s", str + 2); return 0; }
a)
Prints "C Programming"
b)
Prints "Programming"
c)
Causes a compilation error
d)
Results in a runtime error
15.
Which function is used to convert a floating-point number to a string in C?
a)
ftoa()
b)
floattostr()
c)
convertfloat()
d)
strfromfloat()