C/C++ Assessment

C/C++ Assessment

  1. What is the syntax to declare a variable in C/C++?

    a) int x = 10; b) variable x = 10; c) let x = 10;
  2. What is the output of the following C/C++ code snippet?

                            int x = 10;
                            printf("%d", x);
                            x = 20;
                            printf("%d", x);
                        
    a) 1020 b) 2010 c) 1020
  3. Which loop in C/C++ is used to iterate over a range of values?

    a) for b) while c) do...while
  4. In C/C++, what is used to handle error conditions and exceptions?

    a) try b) catch c) finally
  5. What keyword is used in C/C++ to exit a loop prematurely?

    a) break b) stop c) exit
  6. Which C/C++ library is used for input and output operations?

    a) stdio.h b) iostream c) conio.h
  7. In which programming language is the C/C++ code primarily written?

    a) C b) Java c) C++
  8. What will be the output of the following C/C++ code?

                            int a[] = {1, 2, 3};
                            int b[3];
                            b[0] = a[0];
                            b[1] = a[1];
                            b[2] = a[2];
                            printf("%d %d %d", b[0], b[1], b[2]);
                        
    a) 1 2 3 b) 2 1 3 c) 3 1 2