Show List

Quiz - C - 1

79%

Public Average Score
Select the right answer for below questions:

What is the correct syntax for the main function in C?
void main()
int main(void)
int main()
int main()

What is the output of the following code?
#include
int main() {
       int x = 10;
       printf("%d %d %d\n", x, x++,
                 ++x);
       return 0;
}
10 10 11
10 11 11
11 11 11
10 11 11

What is the output of the following code?
#include
int main() {
       int x = 10;
       int y = 20;
       x = x + y;
       printf("x = %d\n", x);
       return 0;
}
x = 10
x = 20
x = 30
x = 30

How do you declare a constant in C?
const int x = 10;
int const x = 10;
#define x 10
const int x = 10;

What is the purpose of the break statement in a loop?
To continue to the next iteration of the loop
To exit the loop immediately
To skip to the next iteration of the loop
To exit the loop immediately

What is the output of the following code?
#include
int main() {
       int x = 10;
       int y = 20;
       if (x < y)
             printf("x is less than y\n");
       else
             printf("x is greater than or equal to y\n");
      return 0;
}
x is less than y
x is greater than y
x is greater than or equal to y
x is less than y

How do you declare a pointer in C?
int *ptr;
*ptr int;
ptr int *;
int *ptr;

What is the output of the following code?
#include
int main() {
        int x = 10;
        int y = 20;
        x = y;
        printf("x = %d\n", x);
        return 0;
}
x = 10
x = 20
x = 0
x = 20

What is the difference between == and = in C?
== tests for equality, while = assigns a value
== assigns a value, while = tests for equality
There is no difference between == and =
== tests for equality, while = assigns a value

What is the value of the following expression in C?
8 % 3
2
3
0
2

Submit
Retry
{"qz1-487376":"int main()","qz1-487377":"10 11 11","qz1-487378":"x = 30","qz1-487379":"const int x = 10;","qz1-487380":"To exit the loop immediately","qz1-487381":"x is less than y","qz1-487382":"int *ptr;","qz1-487383":"x = 20","qz1-487384":"== tests for equality, while = assigns a value","qz1-487385":"2"}

    Leave a Comment


  • captcha text