Skip to content

Commit b2bbb63

Browse files
Add .cpp file
1 parent 48d68bc commit b2bbb63

6 files changed

+120
-0
lines changed

01)helloWorld.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
cout << "Hello World!";
7+
return 0;
8+
}

03)userInput.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int a, b;
7+
cout << "Enter first number: " << endl;
8+
cin >> a;
9+
cout << "Enter second number: " << endl;
10+
cin >> b;
11+
cout << "First number is " << a << " and second number is " << b;
12+
return 0;
13+
}

04)operators.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int a = 5, b = 4;
7+
8+
cout << "Following are the Arithmetic operators:-" << endl;
9+
cout << a << " + " << b << " = " << a + b << endl;
10+
cout << a << " - " << b << " = " << a - b << endl;
11+
cout << a << " * " << b << " = " << a * b << endl;
12+
cout << a << " / " << b << " = " << a / b << endl;
13+
cout << a << " % " << b << " = " << a % b << endl;
14+
cout << a << "++ " << " = " << a++ << endl;
15+
cout << a << "-- " << " = " << a-- << endl;
16+
cout << "++" << a << " = " << ++a << endl;
17+
cout << "--" << a << " = " << --a << endl << endl;
18+
19+
cout << "Following are the Comparision operators:-" << endl;
20+
cout << a << " == " << b << " is " << (a == b) << endl;
21+
cout << a << " != " << b << " is " << (a != b) << endl;
22+
cout << a << " > " << b << " is " << (a > b) << endl;
23+
cout << a << " < " << b << " is " << (a < b) << endl;
24+
cout << a << " >= " << b << " is " << (a >= b) << endl;
25+
cout << a << " <= " << b << " is " << (a <= b) << endl << endl;
26+
27+
cout << "Following are the Logical operators:-" << endl;
28+
cout << "(a==b) && (a>b) is " << ((a == b) && (a > b)) << endl;
29+
cout << "(a==b) || (a>b) is " << ((a == b) || (a > b)) << endl;
30+
cout << "!(a==b) is " << (!(a == b)) << endl;
31+
32+
return 0;
33+
}

15)refrences.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
string var1 = "Value1"; // var1 variable
7+
string &var2 = var1; // reference to var1
8+
9+
cout << "The value of var1 is " << var1 << endl;
10+
cout << "The value of var2 is " << var2 << endl;
11+
12+
var1 = "Value2";
13+
14+
cout << "The new value of var1 is " << var1 << endl;
15+
cout << "The new value of var2 is " << var2 << endl;
16+
17+
return 0;
18+
}

16)pointers.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
float a = 2.2;
7+
float *ptra;
8+
ptra = &a;
9+
10+
cout << "The value of a is " << a << endl;
11+
cout << "The value of &a is " << &a << endl;
12+
cout << "The value of ptra is " << ptra << endl;
13+
cout << "The value of *ptra is " << *ptra << endl;
14+
15+
a = 1.1;
16+
17+
cout << "The new value of a is " << a << endl;
18+
cout << "The new value of &a is " << &a << endl;
19+
cout << "The new value of ptra is " << ptra << endl;
20+
cout << "The new value of *ptra is " << *ptra << endl;
21+
22+
return 0;
23+
}

17)OOPS.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
class Employee // Class
5+
{
6+
public:
7+
string name;
8+
int salary;
9+
10+
void printDetails() // Method
11+
{
12+
cout << "Name of our first employee is " << this->name << endl;
13+
cout << "Salary of our first employee is " << this->salary << endl;
14+
}
15+
};
16+
17+
int main()
18+
{
19+
Employee employee1; // Object
20+
employee1.name = "Mooazam";
21+
employee1.salary = 100000;
22+
employee1.printDetails();
23+
24+
return 0;
25+
}

0 commit comments

Comments
 (0)