Skip to content

Commit f8ab086

Browse files
Cpp Programming
1 parent bb13520 commit f8ab086

26 files changed

+220
-448
lines changed

AccessModifier.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
class Parent {
5+
public:
6+
int x;
7+
8+
protected:
9+
int y;
10+
11+
private:
12+
int z;
13+
};
14+
15+
class Child1 : public Parent{
16+
public:
17+
Child1()
18+
{
19+
cout<<"Hello Children!!!";
20+
}
21+
22+
23+
};
24+
25+
int main()
26+
{
27+
Child1 c;
28+
29+
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
#include<iostream>
22
using namespace std;
3-
43
int main()
54
{
65
int rows;
7-
cout << "Enter the number Rows="<<endl;
6+
cout<<"Enter the number of Rows"<<endl;
87
cin >> rows;
9-
for(int i=0;i<rows;i++)
8+
for(int i=0;i<=rows;i++)
109
{
1110
for(int j=0;j<=i;j++)
1211
{
13-
cout << i+1;
12+
cout<<(char)('A'+i);
1413
}
1514
cout<<endl;
1615
}
17-
return 0;
1816

17+
return 0;
1918

2019
}

AreaofCircle.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
class Circle {
5+
6+
7+
8+
public:
9+
double rad;
10+
double Area()
11+
12+
{
13+
14+
return 3.14*(rad*rad);
15+
16+
}
17+
18+
};
19+
20+
int main()
21+
{
22+
Circle obj;
23+
obj.rad=5.5;
24+
cout<<"Radius is="<<obj.rad<<endl;
25+
cout<<"Area is ="<<obj.Area();
26+
27+
return 0;
28+
29+
}

Array.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int arr[3];
7+
arr[0]=10;
8+
arr[1]=20;
9+
arr[2]=30;
10+
cout<<"arr[0]="<<arr[0]<<endl;
11+
cout<<"arr[1]="<<arr[1]<<endl;
12+
cout<<"arr[2]="<<arr[2]<<endl;
13+
14+
15+
}

Array1.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int table_of_two[10]={2,4,6,8,10,12,14,16,18,20};
7+
for(int i=0;i<10;i++)
8+
9+
{
10+
cout << table_of_two[i]<<" ";
11+
12+
}
13+
return 0;
14+
}

ArraySortAscending.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int arr[5]={5,2,3,8,9};
7+
int a=0,i,j;
8+
for(int i=0;i<arr[5];++i)
9+
{
10+
for(int j=i+1;j<5;++j)
11+
{
12+
if(arr[i]>arr[j])
13+
{
14+
a=arr[i];
15+
arr[i]=arr[j+1];
16+
arr[j+1]=a;
17+
}
18+
}
19+
}
20+
for(int i=0;i<5;i++)
21+
{
22+
cout<<arr[j];
23+
24+
}
25+
26+
}

Ascii.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
char alp='A';
7+
cout<<"The Ascii Value of A "<<alp<<"is "<<int(alp);
8+
9+
}

Basic.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include<iostream>
2+
3+
int main()
4+
5+
{
6+
std::cout<<"Hello World ";
7+
}

BreakNumber.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int num,n1,n2,n3;
7+
cout<<"Enter the number ="<<endl;
8+
cin>>num;
9+
n1=num%10;
10+
num=num/10;
11+
n2=num%10;
12+
num=num/10;
13+
n3=num%10;
14+
num=num/10;
15+
cout<<num*1000<<"+"<<n3*100<<"+"<<n2*10<<"+"<<n1<<endl;
16+
17+
18+
19+
}

Encapsulation.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
5+
class ABC {
6+
int x;
7+
public:
8+
9+
void set(int n)
10+
{
11+
x=n;
12+
}
13+
int get()
14+
{
15+
return x;
16+
}
17+
};
18+
19+
int main()
20+
{
21+
ABC obj;
22+
obj.set(3);
23+
cout<<obj.get()<<endl;
24+
25+
return 0;
26+
27+
}

0 commit comments

Comments
 (0)