C++ Basic 2018 (Batch-2)
765 subscribers
277 photos
11 videos
30 files
74 links
🎯 C++ Basic 2018 (Batch 2) - Pre-Engineering Edition
My second family of coders! πŸ‘¨β€πŸŽ“πŸ‘©β€πŸŽ“
Specifically for 2018 pre-engineering students finding C++ challenging.
We turn confusion into clarity, one concept at a time.
Join the struggle bus - destination
Download Telegram
Shape.pdf
322.1 KB
❀2
To register for the premium class of C++, πŸ‘‰ [@ProgrammingWithFaith_bot] πŸŽ‰
❀1
Media is too big
VIEW IN TELEGRAM
βœ…Pattern Using Loop part one

*
* *
* * *
* * * *
To register for the premium class of C++, πŸ‘‰ [@ProgrammingWithFaith_bot] πŸŽ‰


@ProgrammingWithFaith2018
❀2
❀2
Should I post the Entrepreneurship Business Plan assignment? πŸ“βœ¨

@ProgrammingWithFaith2018
❀5πŸ‘2πŸ”₯1πŸ‘1
C++ Basic 2018 (Batch-2)
Should I post the Entrepreneurship Business Plan assignment? πŸ“βœ¨ @ProgrammingWithFaith2018
I will post it, but you need to share this channel with other students. We need to reach 750 subscribers first.

@ProgrammingWithFaith2018
❀2
βœ…Hawassa University

@ProgrammingWithFaith2018
❀4
C++ Basic 2018 (Batch-2)
Photo
using namespace std;

int main() {
    char pressAletter;

    cout << "Press any character" << endl;
    cin >> pressAletter;

    switch (pressAletter) {

        case 'A':{
       
            int f = 3, g = 4, h, k;
            h = (2 * 34/2 + (g++)) - 4 * f+(++f) + 4 / (++g);
           
           
            k = ++f + g++;
     
     
            cout << "The value of f is: " << f << endl;
            cout << "The value of g is: " << g << endl;
            cout << "The value of h is: " << h << endl;
            cout << "The value of k is: " << k << endl;
            break;}

        case 'B':{
            int num = 5, i = 30;
            do {
                num*=4;
                i++;
            } while (i <= 20);

            cout << "The value of a number is: " << num << endl;
            break;}

        default:
            cout << "You do not have this option" << endl;
    }

    return 0;
}


When we press case "A", it will be executed. Let us compute this:

int f = 3, g = 4, h, k;

h = (2 * 34 / 2 + (g++)) - 4 * f + (++f) + 4 / (++g);
h = (2 * 34 / 2 + 4) - 4 * f + (++f) + 4 / (++g);
h = (38) - (4 * f) + (++f) + (4 / (++g));
h = (38) - 12 + (++f) + 4 / (++g);
h = (38) - 12 + 4 + 4 / 5; // 0.8, but the data type is integer, so it will be 0.
h = (38) - 12 + 4 + 0;
h = 30 - 8 + 0;
h = 30;

k = ++f + g++; // Here, the value of f will increment by one because it is pre-increment: f = 4 + 1 = 5. However, the value of g remains 6 because in the previous line it was incremented twice (once pre-increment and once post-increment), making it 6. Here it is still 6, and after this operation, it will become 7.
k = 5 + 6 = 11.

So finally: h = 30, k = 11, f = 5, g = 7.

When we press B, case "B" will be executed. Let us compute it:
int num = 5, i = 30;
do {
    num *= 4;
    i++;
} while (i <= 20);

cout << "The value of a number is: " << num << endl;

So, it is a do-while loop; it will enter the loop. num = 5 * 4 = 20; then i will be 31. The check if 31 <= 20 is false, so it will terminate the loop and output: The value of a number is 20.

When we press neither A nor B the default part will be executed "You do not have this option"

1. When we press A, what will be the output of lines 14 and 15?
βœ… A (5 & 7)

2. When we press A, what will be the output of lines 16 and 17?
βœ… D (30 & 11)

3. When we press B, what will be the output of line 28?
βœ… B (20)

4. Neither A nor B.
βœ… D (none)

5. The data types of this program are character and integer.
βœ… D (A & B) 
                                                                                                                                       
6.βœ…B(ROM)

@ProgrammingWithFaith2018
❀3
To register for the premium class of C++, πŸ‘‰ [@ProgrammingWithFaith_bot] πŸŽ‰
❀2πŸ‘1
If you have paid for the registration and it is still not approved, DM me  @TechnerdGuy.
❀2
To register for the premium class of C++, πŸ‘‰ [@ProgrammingWithFaith_bot] πŸŽ‰
❀4