Search Header Logo

CP2 / IP FINALS

Authored by Julieann Martinez

Information Technology (IT)

University

Used 9+ times

CP2 / IP FINALS
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

6 questions

Show all answers

1.

FILL IN THE BLANKS QUESTION

1 min • 5 pts

WRITE THE OUTPUT OF GIVEN C++ CODE SNIPPET.

#include <iostream>

using namespace std;

 

int main() {

                   int i = 5;

                   int arr[3] = {2, 4, 6};

 

                                       do {

                                       cout << arr[i % 3] << " ";

                                       i--;

                                       } while(i > 0);

 

                   return 0;

}

​ ​ (a)  

2.

FILL IN THE BLANKS QUESTION

1 min • 5 pts

WRITE THE OUTPUT OF GIVEN C++ CODE SNIPPET.

#include <iostream>
using namespace std;

int main() {
int arr[5] = {1, 3, 5, 2, 4};
int i = 0, count = 0;

                    while(i < 5) {
                    if(arr[i] % 2 == 0) {
                    count++; }
                    else if (arr[i] > 3) {
                    count += 2; }
                    else {
                    count--; }

                    i++;
                    }

                    cout << count;

 return 0;
}

​ ​ (a)  

3.

FILL IN THE BLANKS QUESTION

1 min • 2 pts

WRITE THE OUTPUT OF GIVEN C++ CODE SNIPPET.

#include <iostream>

using namespace std;

 

int main() {

                   int num = 10;

 

                                       if(num > 10) {

                                       cout << "Greater"; }

                                       else {

                                       cout << "Not Greater"; }

 

                   return 0;

}

​ ​ (a)  

4.

FILL IN THE BLANKS QUESTION

1 min • 2 pts

WRITE THE OUTPUT OF GIVEN C++ CODE SNIPPET.

#include <iostream>
using namespace std;

int main() {
int score = 75;

                    if(score >= 90) {
                    cout << "A"; }
                    else if(score >= 80) {
                    cout << "B"; }
                    else if(score >= 70) {
                    cout << "C"; }
                    else {
                    cout << "F"; }

                    return 0;

​ ​ (a)  

5.

FILL IN THE BLANKS QUESTION

1 min • 5 pts

WRITE THE OUTPUT OF GIVEN C++ CODE SNIPPET.

#include <iostream>

using namespace std;

 

int main() {

    int arr[4] = {2, 5, 8, 1};

 

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

        if(arr[i] % 2 == 0)

            cout << "E ";

        else

            cout << "W ";

    }

 

    return 0;

}

​ ​ (a)  

6.

FILL IN THE BLANKS QUESTION

1 min • 5 pts

WRITE THE OUTPUT OF GIVEN C++ CODE SNIPPET.

#include <iostream>

using namespace std;

 

int main() {

    int arr[5] = {1, 4, 6, 7, 10};

 

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

        if(arr[i] > 5)

            cout << "H ";

        else

            cout << "L ";

    }

 

    return 0;

}

​ ​ (a)  

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

Already have an account?