C++ Basic 2018 (Batch-2)
763 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
๐Ÿ“š Stressing over that assignment? Yeah, we get it.

Look, we've all been there deadlines creeping up, exams around the corner, and zero motivation to format another reference page. ๐Ÿ˜ฎโ€๐Ÿ’จ

So here's the deal: we'll take that assignment off your plate while you go crush your finals. ๐ŸŽฏ

โœจ What you get:

ยท โœ… Proper academic formatting that actually looks legit
ยท โœ… A clean, ready-to-submit document
ยท โœ… No stress, no all-nighters, no last-minute panic

๐Ÿ’ก The move is simple stop staring at a blank screen and start focusing on what's actually gonna boost your grades. Let us handle the busy work, you handle the big stuff. ๐Ÿง ๐Ÿ“–


๐Ÿ“ฒ DM @TechnerdGuy

@ProgrammingWithFaith2018
โค2
แˆตแ‰ตแˆ˜แ‹˜แŒˆแ‰ก 50000 BTTC แ‹ญแˆฐแŒฃแ‰นแˆƒแˆ แŠจแ‹› แ‰ แˆ˜แ‰€แŒ แˆ Sign In แ‹จแˆแ‰ตแˆˆแ‹ แ‹แˆตแŒฅ แŒˆแ‰ฅแ‰ณแ‰น 20000 BTTC แ‹ญแˆฐแŒฃแ‰นแˆƒแˆ แŠ แŒ แ‰ƒแˆ‹แ‹ญ แˆแŠ•แˆ แˆณแ‰ตแˆฐแˆฉ 70000 BTTC แ‹ญแˆฐแŒฃแ‰นแˆƒแˆ แŠจแ‹› Withdraw แˆ›แ‹ตแˆจแŒ แАแ‹ fam

๐Ÿ‘‡แˆˆแˆ˜แŒ€แˆ˜แˆญ๐Ÿ‘‡
https://bttcweb.com/pages/register/register?code=7574712
โค1
C++ Basic 2018 (Batch-2)
Final exam 2023_2.pdf
โœ…Answer  ๐Ÿ‘‡

PART I โ€” True or False

1. "If a condition is false, its statement executes and terminates the chain"
Explanation: When a condition is false, its body is skipped, not executed.
โœ… Answer: FALSE       

2. "A function cannot be defined inside another function"
Explanation: In C++, you strictly cannot write a function inside another function.  แ‰  C++ แ‹แˆตแŒฅ แŠ แŠ•แ‹ต function แ‹แˆตแŒฅ แˆŒแˆ‹ function แˆ˜แŒปแ แŠ แ‹ญแ‰ปแˆแˆแข แ‹ญแˆ… แ‹จ C++ แŒฅแ‰ฅแ‰… rule แАแ‹แข
โœ… Answer: TRUE


3. Does *ptr = 11 change i to 11?
Explanation: ptr holds the address of i. Using *ptr means go to that address and change the value โ†’ i becomes 11.                                                                                                 ptr แ‹จ i แŠ• address แ‹ญแ‹Ÿแˆแข *ptr = 11 แˆ›แˆˆแ‰ต "แ‹ˆแ‹ฐ address แˆ‚แ‹ต แŠฅแŠ“ valueแ‹แŠ• แ‰€แ‹ญแˆญ" แˆ›แˆˆแ‰ต แАแ‹ โ†’ i = 11 แ‹ญแˆ†แŠ“แˆแข
โœ… Answer: TRUE


4. Can both foo functions coexist?
Explanation: Yes โ€” this is function overloading. Same name, different parameters = allowed.
โœ… Answer: TRUE


5. Is strlen("Cletus") equal to 7?
Explanation: strlen() counts only the letters โ€” NOT the null character '\0'. "Cletus" = 6 letters โ†’ strlen = 6.
โœ… Answer: FALSE 

PART II โ€” Multiple Choice


Q1. Which array declaration is NOT correct?
Explanation: Arrays must be initialized with curly braces {}, not square brackets [].
โœ… Answer: C


Q2. Which is NOT true?
Explanation: Option B says "when condition is false, the if body executes" โ€” that is completely wrong. When false, the else body runs.
โœ… Answer: B


Q3. Statement for alternate paths based on condition?
Explanation: for and while are loops. The if statement is used for choosing alternate execution paths.
โœ… Answer: A


Q4. Which is TRUE about arrays?
Explanation: Array size must be decided at compile time โ€” you can't change it while the program runs.
โœ… Answer: C


Q6. Correct variable name?
Explanation: Variable names can only have letters, digits, and underscore _. $ and @ are not allowed in C++.
โœ… Answer: B


Q7. Output of str[5]?
Explanation: Counting from index 0: H(0) e(1) l(2) l(3) o(4) space(5) โ†’ space is at index 5.
โœ… Answer: C โ€” Space


Q8. Output of -2 * array[2]?
Explanation: array[2] = 40 (third element). Then -2 ร— 40 = -80.
โœ… Answer: C โ€” -80

Q9. Pointer program output?
Explanation: ptr = x assigns the value 7 as an address โ€” this is wrong. It should be ptr = &x. This causes a compiler error
โœ… Answer: C โ€” Error

Q10. Output of const program?
Explanation: const means the value cannot be changed. Trying a++ on a const variable causes a compiler error.
โœ… Answer: D โ€” Error

Q11. How many times is "CppBuzz.com" printed?
Explanation: i goes from 0 to 4 (when i=5, condition i<5 is false โ†’ no goto). So it prints 5 times.
โœ… Answer: B โ€” 5 times


Q12. Output of a++, b, c?
Explanation: b = a++ means b gets the current value of a (10) first, then a becomes 11. Then c = a โ†’ c = 11. Output: 11 10 11
โœ… Answer: A โ€” 111011

Q13. Variable declared inside a function?
Explanation: A variable declared inside a function only exists within that function โ€” called a local variable.
โœ… Answer: B โ€” Local variable

Q14. Output of car() program?
Explanation: car() is called once in main โ†’ prints "Audi R8" once.
โœ… Answer: A โ€” Audi R8

Q15. Output of fun(x, y)?
Explanation: fun uses pass by value โ€” it receives copies. Changing x and y inside fun does NOT affect the originals in main. So y stays 20.
โœ… Answer: B โ€” 20
                                                                                                                                                                                      PART III โ€” Short Answers

Q1. Declaration of x pointed to by Ptr:
Explanation: To declare a pointer to an integer variable:
int x;
int *Ptr = &x;
Q2. Pass by Value vs Pass by Reference:
Explanation :
Pass by Value -A copy is sent to the function and Original is NOT changed
Pass by Reference-The actual variable is sent using & and Original IS changed

@ProgrammingWithFaith2018
โค1๐Ÿ‘1
void byValue(int x) { x = 100; }    // original value แŠ แ‹ญแ‰€แ‹ญแˆญแˆ
void byRef(int &x)  { x = 100; }    // original value แ‹ญแ‰€แ‹ญแˆซแˆ

Q3. Function Overloading:
Explanation: Multiple functions with the same name but different parameters. The compiler chooses the right one based on the arguments passed.  แŠ แŠ•แ‹ต แˆตแˆ แ‹ซแˆ‹แ‰ธแ‹ แŒแŠ• แ‹จแ‰ฐแˆˆแ‹ซแ‹ฉ parameters แ‹ซแˆ‹แ‰ธแ‹ functionsแข compiler แ‹จแˆšแŒ แˆฉแ‰ แ‰ตแŠ• arguments แ‰ฐแˆ˜แˆญแŠฉแ‹ž แ‰ตแŠญแŠญแˆˆแŠ›แ‹แŠ• function แ‹ญแˆ˜แˆญแŒฃแˆแข
int add(int a, int b)       { return a + b; }   // แˆแˆˆแ‰ต int
float add(float a, float b) { return a + b; }   // แˆแˆˆแ‰ต float
// แŠ แŠ•แ‹ต แˆตแˆ แАแ‹ "add" - แŒแŠ• parameters แ‹ญแˆˆแ‹ซแ‹ซแˆ‰
    

                                                                                                                                                                               
PART IV โ€” Output Questions

Q1. 2D Array output:
Explanation: The loops run only for i=2, j=0 โ†’ that is val[2][0] = 1.
โœ… Output: 1

Q2a. break version:
Explanation: sum=+i means sum = +i (assign), not sum += i (add). When i=3, break fires immediately before assignment.
i=5 โ†’ sum=5, i=4 โ†’ sum=4, i=3 โ†’ break!

โœ… Output: 4

Q2b. continue version:
Explanation: continue skips to the next iteration. sum+=i comes after continue so it never executes. Sum stays 0.
โœ… Output: 0

Q3. String program:
Explanation: strncpy(z, y, 9) copies first 9 characters of y into z. Then z[9]='\0' ends the string.
โœ… Output:
String y: It is a nice day
String z: It is a n

Q
4. Swap function:

Explanation : A is pass by value (copy), B is pass by reference (real). So only b changes in main.
A=4+18=22 (local), B=22-18=4 (b in main changes!), A=22-4=18 (local only)
Back in main: a=4, b=4
โœ… Output: 4, 4


PART V โ€” Programs


Q1. Income Tax
using namespace std;
int main(){
    float salary, tax = 0;
    cout << "Enter salary: ";
    cin >> salary;

    if(salary <= 200)
        tax = 0;
    else if(salary <= 600)
        tax = (salary - 200) * 0.10;
    else if(salary <= 1200)
        tax = 400*0.10 + (salary - 600)*0.15;
    else if(salary <= 2000)
        tax = 400*0.10 + 600*0.15 + (salary-1200)*0.20;
    else if(salary <= 3500)
        tax = 400*0.10 + 600*0.15 + 800*0.20 + (salary-2000)*0.25;
    else
        tax = 400*0.10 + 600*0.15 + 800*0.20 + 1500*0.25 + (salary-3500)*0.30;

    cout << "Income tax = " << tax << " Birr" << endl;
    return 0;
}

Q2. Count students below 45
using namespace std;
int main(){
    int n, mark, count = 0;
    cout << "Enter number of students: ";
    cin >> n;
    for(int i = 0; i < n; i++){
        cout << "Enter mark for student " << i+1 << ": ";
        cin >> mark;
        if(mark < 45)
            count++;
    }
    cout << "Students below 45: " << count << endl;
    return 0;
}

Q3. Enter until negative
using namespace std;
void enterNumbers(){
    int num;
    while(true){
        cout << "Enter a number: ";
        cin >> num;
        if(num < 0){
            cout << "Now you have entered a negative number" << endl;
            break;
        }
    }
}
int main(){
    enterNumbers();
    return 0;
}


@ProgrammingWithFaith2018
โค4
If anyone has last year's C++ final exam, please post it here in the comment section. ๐Ÿ’ป๐Ÿ“

@ProgrammingWithFaith2018
๐Ÿ“ฒ
1.

Function declaration malet just le compilerแˆ sle function แˆ˜แŠ•แŒˆแˆญ nw

Syntax : datatypes  functions_name(parameters )

Example

int sum(int a,int b)
with parameter
int sum() without parameter


So

Answer:) D
Because it lack return type


2.
ANSWER:) A

We define structure first then we create a variable @ProgrammingWithFaith2018
โค3
3.
To create 2D array the syntax is:)
Datatypes array[row][column ]

int array[10][5];

Answer :) C

4.

Answer :) A
โค2
5.

Arrya is collection of elements with the same data types.

To access first element of array we use

Array[0]

To access the last

Array[n-1]

But to access the memory address of first element just we call it's name

for example int ages[]={1,3};
ages // to access the memory address of first element

So

โœ…Answer :)D

6.

Strcpy(a,b) copies the entire string from b to a

So

โœ…Answer :) A
โค3
7.

For loop that run from 5 to 105 in steps of 4

for (int i=5;i<=105;i+=4)

โœ…Answer:) A


8.

Do while is different from while in the code in do while is executed at least once.

โœ…Answer:) B
โค4
9.

Break :) terminates execution immediately .

โœ…Answer D
โค5๐Ÿ‘Ž2
Forwarded from Hustler Hub (โœžFaithโœž)
แŠซแˆแŠ‘ viral แˆณแ‹ญแ‹ˆแŒฃ แŒ€แˆแˆฉ

แˆ˜แŒ€แˆ˜แˆชแ‹ซ link แŠ•แŠฉแ‰ต แ‰ แˆ˜แ‰€แŒ แˆแˆ แ‹ˆแ‹ฐ playstore แˆฒแ‹ˆแˆฐแ‹ณแ‰ฝแˆ app download แŠฃแˆญแŒ‰แ‰ต แˆแŠญ แˆฒแŠจแแ‰ตแˆ‹แ‰ฝแˆ แ‰  google account แŠญแˆแ‰ฑ แŠฃแˆˆแ‰€

โœ…แ‰ แ‰ฐแˆจแˆ แˆฐแ‹ แŒ‹แ‰ฅแ‹™,video แ‰ แˆ›แ‹จแ‰ตแˆ แ‹ญแŠจแแˆ‹แˆ
1 invitatin -  1$$$$$

แŒแŠ• แ‰ถแˆŽ แŒ€แˆแˆฉ

แ‹ซแˆแŒˆแ‰ฃแ‰ฝแˆ แАแŒˆแˆญ แŠซแˆˆ แŒ แ‹ญแ‰แŠ

link๐Ÿ‘‡
https://play.google.com/store/apps/details?id=com.app.cash.adda.playandwin

1000 coin =1$ แˆˆแˆ˜แ‰€แ‰ แˆ แŠจแ‰ณแ‰ฝ แ‹ซแˆˆแ‹แŠ• Referral code copy แŠ แˆญแŒ‹แ‰ฝแˆ แˆ™แˆ‰
                ๐Ÿ‘‡๐Ÿ‘‡
M97b6xshpKQNOLUkbKwc2T1gxPw2

@examanswer1
๐Ÿ˜2โค1