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
βœ…Exercise: Increment and Decrement


‎1. int a=5;
‎  int  x=++a + ++a;
‎  cout<<x;


‎2. int a=5;
‎   int b=6;
‎   Cout<< ++a + b++;
‎   Cout<<b;

‎3. int x, a, b, c;
‎a = 2;
‎b = 4;
‎c = 5;
‎x = a--+ b++ -++c;
‎cout<<x;

‎4. int x, a;
‎a = 2;
‎x = ++a *--a *++a;
‎cout<<x;

‎5. int x, a = 4;
‎x = ++a + ++a + ++a;

‎cout<<x;

@ProgrammingWithFaith2018
❀3πŸ”₯2
βœ… ‎Hint:‎One variable can't store two value at the same time.


1.int a=5;
‎int x=++a + ++a;
‎(6+ ++a)
‎(7+7) because one variable can't hold two different value , (6 and 7 ) at the same time so it become 7.

‎7+7=14


Answer 14


2.int a=5;
‎   int b=6;
‎   
‎   Cout<<++a +b++// post and pre increment .
‎  6+6 // after this line b will be 7
‎Cout<<++a +b++;  (6+6)
‎  =12
‎Cout<<b;
‎=7


answer=12 and 7


3.int x,a,b,c;
‎a=2;
‎b=4;
‎c=5;
‎x=a-- + b++ - ++c;

‎(2+4)-6
‎=6-6=0
‎cout<<x;  


Answer   0


4.int x,a;
‎a=2
‎x=++a *--a* ++a
‎(3*2) * ++a , but one variable can't hold two values at the same time.

‎So, (2*2)*++a
‎    (4*3)=12

‎cout<<x;// 12


Answer 12



5.int x,a=4;
‎x=++a + ++a + ++a;

‎(++a + ++a) + ++a
‎(5+6) + ++a but we can't store two value at one variable at the same time.

‎So,
‎(6+6)+ ++a
‎(12)+ 7


Answer 19


@ProgrammingWithFaith2018
❀5πŸ”₯3😁1
If you ever find it difficult to understand questions and concepts like these, join our premium class. We make everything easy to understand for you.

βœ…For registration:[ @ProgrammingWithFaith_bot ]
❀1
🎲 Quiz 'C++ Chapter One'
πŸ–Š 16 questions Β· ⏱ 1 min
πŸ”₯2❀1
To register for the premium class, πŸ‘‰ [@ProgrammingWithFaith_bot] πŸŽ‰
πŸ”₯1
Do you have any questions? πŸ€” Just ask me anonymously, and I will answer them here!πŸ’¬πŸ˜Š
link: [ https://sma.robi.work/b/bqkJIHVlXiTl ]
❀1πŸ‘1
u forgot to include return 0: and } 🀭
😁2
I recommend that u study based on the exam format, and to be good at programming, you should understand the theory first. Once you grasp how things work, it will become easier.
❀4
Computer Science
❀2
For now, I haven't built a very strong portfolio, but I can show you some of my projects.
https://movie-review-app-pi-two.vercel.app/

For more , you can join my personal channel where I share what I do. @SelfTaughtDev1
❀1
Do you have a Telegram channel? Are you already monetizing it? πŸ€” Try Inside Ads β€” I’ve already started earning. Here’s the link:

https://t.me/InsideAds_bot/open?startapp=r_1876122021
πŸ”₯2
βœ…Exercise

What is the output of this code? If there is an error, fix it and explain why it occurs.

#include <iostream>
using namespace std;


void add();

int main() {
int age = 21;
add();
return 0;
}

void add() {
cout << "Age: " << age << endl;
}



@ProgrammingWithFaith2018
❀2πŸ₯°2πŸ”₯1
#include <iostream>
using namespace std;

int age = 21;

void add() {
cout << "Age: " << age << endl;
}

int main() {
add();
return 0;
}


Error: variable age is not local to the function ⚠️

This one is also possible βœ…

#include <iostream>
using namespace std;
int age = 21;

void add();

int main() {
add();
return 0;
}

void add() {
cout << "Age: " << age << endl;
}

Output: 21 πŸš€

@ProgrammingWithFaith2018
❀2πŸ₯°2
To register for the premium class, πŸ‘‰ [@ProgrammingWithFaith_bot] πŸŽ‰
❀2
❀2