If Else

BASIC QUESTIONS

  1. Why we use #include statement in program.
  2. See Answer Ans: #include statement is used to include library files required for various library functions. eg. iostream.h is needed for cout and cin objects and stdio.h is needed for printf() and scanf() function.

  3. What is main()?
  4. See Answer Ans: main() is a function from where program execution starts.

  5. Data types available in C/C++?
  6. See Answer Ans: int , long int, float, long float(double), long double, char, unsigned int, unsigned char.

  7. Size and range of int and long int.
  8. See Answer Ans: int :- Size: 4 Bytes(window based compilers), Range: -231 to 231-1.
            long int: Size 8 Bytes (window based compilers), Range: -263 to 263-1.

  9. Size and range of float and long double.
  10. See Answer Ans: float :- Size: 4 Bytes(window based compilers), Range: 1.2-38 to 3.438.
            long double: Size 10 Bytes (window based compilers), Range: 3.4-4932 to 1.14932.

  11. Diff b/w Mod(%)and Divide(/).
  12. See Answer Ans: Division(/) used for getting quotient value where as module(%) is used for getting remainder value.

  13. What will be the output of:
    1. int x=5/2;
    2. See Answer Ans: 2

    3. float x=5/2;
    4. See Answer Ans: 2.000000

    5. float 5.0/2;
    6. See Answer Ans: 2.500000

  14. What will be the output of:
    1. int x=8.0%3;
    2. See Answer Ans: Error: Mod never works with float.

  15. What will be the output of:
    1. float discount=10/100*8000.0;
    2. See Answer Ans: 0. because 10/100 generates 0. (int/int = int).

  16. What is hierarchy/precedence of arithmetic operators in C/C++.
  17. See Answer Ans: Order of execution of arithmetic operators in an expression is known as hierarchy.

  18. What is a Variable?
  19. See Answer Ans: A storage location in memory.

  20. What is Token?
  21. See Answer Ans: A token is the smallest element of a program that is meaningful to the compiler. Tokens can be classified as follows:
    1. Keywords
    2. Identifiers
    3. Constants
    4. Strings
    5. Special Symbols
    6. Operators

  22. What will be the output of:
    1. int x=-5%2;
    2. See Answer Ans: -1 (The sign of numerator will be the sign of result).

    3. int y=5%-2;
    4. See Answer Ans: 1 (The sign of numerator will be the sign of result).

    5. int z=-5%-2;
    6. See Answer Ans: -1 (The sign of numerator will be the sign of result).

  23. What is Explicit type casting?
  24. See Answer Ans: In computer science, type conversion or typecasting refers to changing an entity of one datatype into another. There are two types of conversion: implicit and explicit. The term for implicit type conversion is coercion. Explicit type conversion in some specific way is known as casting.

  25. What is Printf()and Scanf()?
  26. See Answer Ans: printf() and scanf() are functions.

  27. Does Printf() return any Value?
  28. See Answer Ans: yes printf() return int value.
           It return no. of characters printed on screen.
    eg. int x=printf("BCE");
    printf("%d",x); //3