Bird
0
0
DSA Cprogramming~10 mins

String Basics and Memory Representation in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a string variable in C.

DSA C
char name[] = [1];
Drag options to blanks, or click blank then click option'
A"Hello"
B'Hello'
CHello
D"H"
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes for strings
Not using quotes at all
2fill in blank
medium

Complete the code to print the first character of the string.

DSA C
printf("%c", name[1]);
Drag options to blanks, or click blank then click option'
A(0)
B[1]
C[0]
D.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of brackets
Starting index at 1
3fill in blank
hard

Fix the error in the code to copy one string to another.

DSA C
strcpy(dest, [1]);
Drag options to blanks, or click blank then click option'
A&source
Bdest
C*source
Dsource
Attempts:
3 left
💡 Hint
Common Mistakes
Passing destination as source
Using & or * operators incorrectly
4fill in blank
hard

Fill both blanks to declare and initialize a string pointer.

DSA C
char *ptr = [1];
Drag options to blanks, or click blank then click option'
A'World'
B"World"
Cptr
DWorld
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes for strings
Not using quotes at all
5fill in blank
hard

Fill all three blanks to print the length of a string using strlen.

DSA C
int len = strlen([1]);
printf("Length: %[2]\n", [3]);
Drag options to blanks, or click blank then click option'
Astr
Bd
Clen
Dstrcpy
Attempts:
3 left
💡 Hint
Common Mistakes
Using %c instead of %d for printing length
Passing wrong variable to strlen