SHORT QUESTIONS-GS

Q1. What are tokens in C++? How many types of tokens are allowed in C++? Exemplify your answer.

Q2. How are keywords different from identifiers?

Q3. Identify the errors in the following code segments:

     1. int main ( ) { cout << “Enter two numbers”;

         cin>>num>>auto;

        float area = Length * breath; }

    2. #include<iostream.h>

         void Main ( )

         {        int a,b;

                  cin<< >>b;

                  if(a > b) MAX =a

        }

Q4. What are literals in C++? How many types of literals are allowed in C++?

Q5. How are integer constants represented in C++? Explain with examples.

Q6. What are character constants in C++? How are these implemented?

Q7. Can nongraphic characters be used and processed in C++? How? Give examples to support your answer.

Q8. How are floating constants represented in C++? Give examples to support your answer.

Q9. How are string-literals represented and implemented in C++?

Q10. What are operators? What is their function? Give examples of some unary and binary operators?

Q11. Why is it important to include iostream.h in C++ programs?

Q12. How are files and devices implemented at the lowest level?

Q13. What is the function of I/O library in C++?

Q14. What are stream in C++? What are predefined streams in C++? What are their functions?

Q15. Why is main() function so important?

Q16. Find out the errors, if any, in the following C++ statements:

  1. cout<<”a=” a;
  2. m=5, n=12; o=15
  3. cout<<”x”;<<x;
  4. cin>>y;>>j;
  5. cin>>”\n”>>y;
  6. cout>>\n”abc;
  7. a=b+c
  8. break=x*y;

Q17. Write a program to display the following output using a single cout statement.

Program = 20

Documentation = 23

Logic = 21

Flow chart = 18

Q18. Write a program to read values of w, x, y and z and display the value of P, where

P= w+x / y-z

Q19. Write a C++ program that reads temperature in Celsius and displays it in Fahrenheit.

Q20. Write a program that displays on screen

  1. the character ‘z’
  2. the name ‘Mohan’
  3. the number 1977

Using

  1. single cout statement
  2. multiple cout statements.

Q21. Assuming that there are 7.481 gallons in a cubic foot, write a program that asks the user to enter the number of gallons, and then displays the equivalent in cubic feet.

Q22. Write a program to generate the following table:

          1992                     17421

          1993                     29210

          1994                     100523

          1995                     106802

          1996                     127000

Use a single cout statement for output.

(Hint : Make use of \n and \t)

Q23. Write a program that generates the following output:

          5

          10

          9

Assign value 5 to a variable using = . Multiply it with 2 to generate 10 and subtract 1 to generate 9.

Q24. Write a C++ program that accepts radius of a circle and prints its area.

Q25. Write a C++ program to print the output mentioned in question 23 in different lines, that is, all values must appear in the different lines.

Q26. Write a C++ program that accepts marks in 5 subjects and outputs average marks.

Q27. Write a C++ program to accept two integers and print their sum.

%d bloggers like this: