0
0
Cprogramming~10 mins

Why C is widely used - Test Your Understanding

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

Complete the code to print "Hello, World!" in C.

C
#include <stdio.h>

int main() {
    [1]("Hello, World!\n");
    return 0;
}
Drag options to blanks, or click blank then click option'
Aprint
Bprintf
Cecho
Dcout
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'print' or 'echo' which are not C functions.
2fill in blank
medium

Complete the code to declare an integer variable named 'count' in C.

C
[1] count = 10;
Drag options to blanks, or click blank then click option'
Aint
Bfloat
Cstring
Dchar
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'float' for integers or 'string' which is not a C type.
3fill in blank
hard

Fix the error in the code to correctly include the standard input/output header.

C
#include [1]
Drag options to blanks, or click blank then click option'
A<stdio>
B"stdio"
C"stdio.h"
D<stdio.h>
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes instead of angle brackets or missing '.h' extension.
4fill in blank
hard

Fill both blanks to declare a pointer to an integer and assign it the address of variable 'num'.

C
int num = 5;
[1] *ptr;
ptr = [2];
Drag options to blanks, or click blank then click option'
Aint
B&num
Cnum
Dfloat
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the value instead of the address to the pointer.
5fill in blank
hard

Fill all three blanks to define a function named 'add' that takes two integers and returns their sum.

C
[1] add([2] a, [3] b) {
    return a + b;
}
Drag options to blanks, or click blank then click option'
Aint
Dvoid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'void' as return type or parameter types.