Answer the fallowing Questions:
Q.1:
- Explain why in C++ the function main() is a special function and why it is important.
- Fill in the blanks in the following:
- An error which is caught by the compiler is a ______ error.
- The operator that tests for equality is _____.
- The do-while statement terminates when its condition is______.
- ______ is a type with no objects.
- The elements of an array are related by the fact that they have the same _____ and_____.
Q.2:
- Explain how information is passed to and returned from a function.
- Given the following definition of a Swap function
void swap (int x, int y)
{
int temp = x;
x = y;
y = temp;
}
What will be the value of x and y after the following call?
x = 10;
y = 20;
swap(x, y);
Q.3:
- Explain what is meant by precedence and why it is important in programming, using arithmetic examples to illustrate your answer. What are the precedence rules for the arithmetic operators in C++?
- Write a C++ program which produces a simple multiplication table of the following format for integers in the range 1 to 9:
1 x 1 = 1
1 x 2 = 2
...
9 x 9 = 81
Q.4:
- Explain what is meant by keyword? Give an example.
- Write a function which outputs all the prime numbers between 2 and a given positive integer n:
void primes ( int n );
A number is prime if it is only divisible by itself and 1.
Q.5:
- Explain what is meant by assignment illustrating your answer with appropriate examples.
- Write a function that inputs a series of 7 numbers from the keyboard into an array and then prints them to the screen with a + symbol after each number. For example if the numbers entered were 1, 4, 5, 7, 9, 30, 45, the following would be printed to the screen:
These are the numbers input: 1 + 4 + 5 + 7 + 9 + 30 + 45 +
Good Luck….