Final Assessment C++

Welcome to your Final Assessment C++

1. Main function cannot have a list of parameters
2. Fill in the gaps in order to create a variable which will store the result of the addittion of two variables called a and b and print the result.

int a=10;

int b=5;

result=

cout<<

3. Select from the following list only what could be a valid identifier for a variable or a constant.
4. MyVar and myVar are the same identifier.
5. The following lines will create an error.

const int myNum=10;

myNum=20;

6. Please fill in the correct data type for each variable declaration-initilization

____ firstNumber=9;

____ secondNumber=8.99;

____ alphabetLetter=a;

____ result=false;

____ myText=”Hello World”

7. Which will be the value of variable myVar after the following lines of code are executed?

int myVar=5;

myVar=myVar+5;

--myVar;

8. Fill in the correct operator in order to add 5 to the variable x.

int x=10;

x=5;

9. Fill in the correct operator to increase the variable x by one.

int x=10;

10. What will be printed after the execution of the following lines of code?

int varA=2;

int varB=4;

varA=varB;

cout<<varA<<“,”<<varB;

11. Fill in the gap below in order for myBool variable to be true

string wordA=“cat”;

string wordB=“dog”;

bool myBool=(wordA =wordB);

12. Select the value which x will have once the following lines of code are executed.

int x;

x=2+3%4;

13. Select the value which x will have once the following lines of code are executed.

int x=10;

int y=20;

int z=30;

x=y=z;

14. What message will be printed after the execution of the following lines of code?

int age=6;

if (age<4)

                cout<<”Junior. No school.”;

else if (age>=4 && age<6)

                cout<<”Nursery.”;

else if (age>=6 && age<12)

                cout<<”Elementary School.”;

else if (age>=12 && age<18)

                cout<<”Secondary School”;

else

cout<<”Adult. No school”;

15. Fill in the gaps in the following lines of code in order to print the variable i as long as it is less or equal to 10.

int i;

(i<=10){

                cout<< ;

                i++;

}

16. Fill in the gaps in the following lines of code in order to find and print the sum of the 10 first natural numbers.

int sum;

for (int i= ;i< ;i++){

                sum= + ;

}

cout<<”The sum is ”<

17. Fill in the gaps in the following lines of code in order to give a new value to the 3rd position of an array and print all of its elements.

int myIntegers[ ] = {1,2,3,4,5};

cout<<"insert the value"<
cin>>myIntegers[ ];

for (int i=0;i<5;i++)

cout< ];

18. What is printed after the execution of the following lines of code?

int k=5;

int i=-2;

do{
                i=i+2;

                --k;

} while (i<=k);

cout<<i+k;

19. Which of the following is true?
20. Fill in the gaps in order to create the function called myFunction which will print the string “This is my function” when it is given as its paremeter.

myFunction ( myString){

                cout<

}

int main(){

               

                return 0;

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »