CPP Day 1
CPP Day 1
#include<iostream>
using namespace std;
int main ()
{
// 1) \n --> New line
cout<<"\nNepal is a beautyfull\ncountry";
// 2) \t --> Horzontal tab
cout<<"\nIndia\tis\tgreat";
// 3) \a Audible bell
cout<<"\nrajan \a rajak";
// 4)\b -->Backspace
cout<<"\nindia is\b greate";
// 5) \r --> Carrige return
cout<<"\nIndia is\r great";
// 6) \\ Shows backward slash(\)
cout<<"\nNumber1\\Number2";
// 7) \' Single quotes
cout<<"\nI\'m a good boy";
// 8)\" Double quotes
cout<<"\nMy name\"Rajan";
// 9) \? Question marks
cout<<"What is your name \?";
// 10) \0 Null character
cout<<"What is\0 this";
// 11) \x--> Hexadecimal
// 12) \o --> Octal number
// 13) \v --> Vertical tab
// 14) \f--> Form feed(feed one blank page before starting the printing)
}
// 02 Uses of reference
#include <iostream>
using namespace std;
int main()
{
int a=10;
int &b = a; // refernce variable
cout << "a ="<<a<<endl;
cout << "b="<<b<<endl;
b++;
cout << "new a ="<<a<<endl;
cout << "new b="<<b<<endl;
}
// 03 Uses of typedef
#include <iostream>
using namespace std;
int main()
{
typedef float currency;
currency amount;
amount = 1500;
cout << "\nAmount ="<<amount;
// 04 Uses of enum
#include <iostream>
using namespace std;
int main()
{
enum day {sun,mon,tue,wed,thu,fri,sat};
day d;
d=sun;
cout << "\nd ="<<d;
cout << "\nthu ="<<thu;
}