DSA USING CPP:

by pallavi

To print in different lines: \n or we can use std::endl

 

Giving input by user:

Instead of using std:: every time we can use namespace

If you want to take int or anything as a input. We use cin>>:

bits/stdc++.h - it includes all the libraries in c++

 

Here we are using string datatyp

 

But if we give input as : hey pallavi

it will only give output as hey

So if we want to get all the hey pallavi as output we have to define another string

So if we want to do that in one string we have to use getline

here input : hey pallu

output : hey pallu

-> for char we declare it in single quotes

 

Q) write a program that takes input as age and prints if you are adult or not:( if-else)

Q)

SWITCH STATEMENTS:

Q) Take the day number and print the corresponding day.

ex: for 1 print monday

Input - 2

output - tuesday

 

Input - 19

output - invalid