Search This Blog

Love Babbar's C++ DSA Lecture's Solutions

  1. Lecture: 1 Homework Solutions
  2. Lecture: 2 Homework Solutions
  3. Lecture: 3 Homework Solutions
  4. Lecture: 4 Homework Solutions
  5. Lecture: 5 Homework Solutions
  6. Lecture: 6 Homework Solutions
  7. Lecture: 7 Homework Solutions

Homework of Video 4 ( Solving Pattern Questions (Part-2) ) - Love babbar

1. Write a program to print this pattern:

1
2 3
4 5 6
7 8 9 10


2. Write a program to print this pattern:

1
2 3
3 4 5
4 5 6 7


3. Write a program to print this pattern:

A B C
A B C
A B C


4. Write a program to print this pattern:

A B C
D E F
G H I


5. Write a program to print this pattern:

A B C
B C D
C D E


6. Write a program to print this triangular pattern:

A
B B
C C C


7. Write a program to print this triangular pattern:

D
C D
B C D
A B C D


8. Write a program to print this square matrix pattern:

****
***
**
*


9. Write a program to print this square matrix pattern:

****
***
**
*



10. Write a program to print this square matrix pattern:

1111
222
33
4


11. Write a program to print this square matrix pattern:

1
22
333
4444


12. Write a program to print this square matrix pattern:

1234
234
34
4


13. Write a program to print this square matrix pattern:

1
23
456
78910


14. Write a program to print this square matrix pattern:

1234554321
1234**4321
123****321
12******21
1********1

Homework of Video 3 ( If-Else, While loop & Lots of Patterns (Part-1) ) - Love babbar


1. Why do we write namespace std & iostream as the program's header?

Ans. These are pre-built libraries where a code related to performing a certain task is placed So that, C++ can work effectively.

a. Using namespace std: There are a bunch of namespaces & out of them we are using std that makes the computer know that we are using cout. Basically, an identifier conflict resolver.

b. #include <iostream> : This header contains the programs of input & output functions like cout,cin etc. #include asks to include iostream


2. Guess the output :


Ans: NINEYPOSITIVE



Ans: 3


Ans: Love24

3. Write a code that accepts char ch. 

  • Prints this is the lowercase or small case if lies in between 'a' - 'z'
  • Prints this is uppercase  if lies in between 'A' - 'Z'
  • Prints this is numeric if lies in between '0' - '9'


4. Input N and print the sum of all the even numbers lying in 1 to N.



5.  Write a program to convert the temperature into:
  • Fahrenheit to celsius
  • Celsius to Fahrenheit