Skip to content

Commit 60f2f9e

Browse files
committed
Adding C++ Program
1 parent 04d0f7d commit 60f2f9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1827
-0
lines changed

Add2No.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main(){
5+
int a , b ;
6+
cout<<"Enter the 1st No : ";
7+
cin>>a;
8+
cout<<"Enter the 2nd No : ";
9+
cin>>b;
10+
cout<<"The addition to a and b is "<<a+b;
11+
return 0 ;
12+
}
13+
14+
/* OutPut :
15+
16+
Enter the 1st No : 45
17+
Enter the 2nd No : 24
18+
The addition to a and b is 69
19+
20+
*/

ArrayMultitable.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main(){
5+
int table[10];
6+
int i = 0 ;
7+
for( i = 0 ; i < 10 ; i++){
8+
table[i] = 5 * (i + 1 );
9+
}
10+
for(int i = 0 ; i < 10 ; i++){
11+
cout<<"5 X "<<i+1<<" = "<<table[i]<<endl;
12+
}
13+
14+
// // TO Print the Content in array
15+
// for(int i = 0 ; i < 10 ; i++){
16+
// cout<<table[i]<<endl;
17+
// }
18+
19+
return 0;
20+
}
21+
22+
/*
23+
Using array Creating table :
24+
Output :
25+
26+
5 X 1 = 5
27+
5 X 2 = 10
28+
5 X 3 = 15
29+
5 X 4 = 20
30+
5 X 5 = 25
31+
5 X 6 = 30
32+
5 X 7 = 35
33+
5 X 8 = 40
34+
5 X 9 = 45
35+
5 X 10 = 50
36+
37+
*/

Arrays.cpp

Lines changed: 33 additions & 0 deletions
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+
// Arrays in C++
7+
// Simple Program Take MArks as Input and Print them
8+
int marks[4];
9+
cout << "Enter the Marks for English , Hindi , Maths and Science : " << endl;
10+
cin >> marks[0] >> marks[1] >> marks[2] >> marks[3];
11+
cout << "The Marks of English is " << marks[0] << endl;
12+
cout << "The Marks of Hindi is " << marks[1] << endl;
13+
cout << "The Marks of Maths is " << marks[2] << endl;
14+
cout << "The Marks of Science is " << marks[3] << endl;
15+
16+
;
17+
return 0;
18+
}
19+
20+
/*
21+
Output :
22+
23+
Enter the Marks for English , Hindi , Maths and Science :
24+
45
25+
25
26+
36
27+
45
28+
The Marks of English is 45
29+
The Marks of Hindi is 25
30+
The Marks of Maths is 36
31+
The Marks of Science is 45
32+
33+
*/

ArraysPr2.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
// Using Array Creating Multiplication Table
5+
6+
int main(){
7+
int num ;
8+
int table[10];
9+
cout<<"Enter the Num : ";
10+
cin>>num;
11+
for(int i = 0 ; i < 10 ; i++){
12+
table[i] = num * (i + 1);
13+
14+
}
15+
for(int i = 0 ; i < 10 ; i++){
16+
cout<<num<<" X "<<i+1<<" = "<<table[i]<<endl;
17+
}
18+
19+
return 0;
20+
}
21+
22+
23+
/*
24+
Output :
25+
26+
Enter the Num : 9
27+
9 X 1 = 9
28+
9 X 2 = 18
29+
9 X 3 = 27
30+
9 X 4 = 36
31+
9 X 5 = 45
32+
9 X 6 = 54
33+
9 X 7 = 63
34+
9 X 8 = 72
35+
9 X 9 = 81
36+
9 X 10 = 90
37+
38+
*/

Compare.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 a, b;
7+
cout << "Enter the Value of a : ";
8+
cin >> a;
9+
cout << "Enter the value of b : ";
10+
cin >> b;
11+
cout << "The Sum of Two Value is " << a + b << endl;
12+
13+
return 0;
14+
}

Cons3.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include<iostream>
2+
#include<math.h>
3+
using namespace std;
4+
5+
class Point{
6+
int x ,y ;
7+
public:
8+
friend double differencebetween(Point , Point);
9+
Point(int a , int b){
10+
x = a ;
11+
y = b ;
12+
}
13+
14+
void displaypoint(){
15+
cout<<"The point is ("<<x<<" , "<<y<<")"<<endl;
16+
}
17+
};
18+
19+
double differencebetween(Point p1 , Point p2){
20+
double res = sqrt(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2));
21+
return res;
22+
}
23+
24+
int main(){
25+
Point p(1 ,0);
26+
p.displaypoint();
27+
28+
Point q(70 ,0);
29+
q.displaypoint();
30+
31+
double result = differencebetween(p,q);
32+
cout<<"The Distance Between Point p and q is "<<result<<endl;
33+
return 0;
34+
}
35+
36+
/*
37+
OutPut :
38+
39+
The point is (1 , 0)
40+
The point is (70 , 0)
41+
The Distance Between Point p and q is 69
42+
43+
*/

Constructor.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
class Complex
5+
{
6+
int a, b;
7+
8+
public:
9+
Complex(void);
10+
void printnumber(void){
11+
cout<<"Your Number is "<<a<<" + "<<b<<"i "<<endl;
12+
}
13+
};
14+
15+
Complex :: Complex(void){
16+
cout<<"Enter the No : ";
17+
cin>>a;
18+
cout<<"Enter the No : ";
19+
cin>>b;
20+
21+
}
22+
23+
int main()
24+
{
25+
Complex c1;
26+
c1.printnumber();
27+
return 0;
28+
}
29+
30+
/*
31+
OutPut :
32+
33+
Enter the No : 5
34+
Enter the No : 4
35+
Your Number is 5 + 4i
36+
37+
*/

Constructor2.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
class Point{
5+
int x ,y ;
6+
public:
7+
Point(int a , int b){
8+
x = a ;
9+
y = b ;
10+
}
11+
12+
void displaypoint(){
13+
cout<<"The point is ("<<x<<" , "<<y<<")"<<endl;
14+
}
15+
};
16+
17+
int main(){
18+
Point p(1 ,1);
19+
p.displaypoint();
20+
return 0;
21+
}
22+
23+
/*
24+
OutPut :
25+
26+
The point is (1 , 1)
27+
28+
*/

Constructor4.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
class BankDeposit
5+
{
6+
int Amount;
7+
int Years;
8+
float Interest;
9+
float returnvalue;
10+
11+
public:
12+
BankDeposit(){};
13+
BankDeposit(int a , int y , int i);
14+
BankDeposit(int a , int y , float i);
15+
void show();
16+
};
17+
18+
19+
BankDeposit :: BankDeposit(int a, int y, int i)
20+
{
21+
Amount = a;
22+
Years = y;
23+
Interest = float(i)/100;
24+
returnvalue =Amount;
25+
for (int i = 0; i < y; i++)
26+
{
27+
returnvalue = returnvalue * (1+Interest);
28+
}
29+
}
30+
31+
BankDeposit :: BankDeposit(int a , int y , float i){
32+
Amount = a ;
33+
Years = y ;
34+
Interest = i ;
35+
returnvalue = Amount;
36+
for(int i = 0 ; i < y ; i++){
37+
returnvalue = returnvalue * (1+Interest);
38+
}
39+
}
40+
41+
void BankDeposit :: show(){
42+
cout<<endl<<"Principal amount was "<<Amount
43+
<< ". Return value after "<<Years
44+
<< " years is "<<returnvalue<<endl;
45+
}
46+
47+
int main()
48+
{
49+
BankDeposit bd1 , bd2 ;
50+
int a, y;
51+
float i;
52+
int R;
53+
54+
cout<<"Enter the Value of a , y and i"<<endl;
55+
cin>>a>>y>>i;
56+
bd1 = BankDeposit(a ,y , i);
57+
bd1.show();
58+
59+
cout<<"Enter the Value of a , y and i"<<endl;
60+
cin>>a>>y>>R;
61+
bd2 = BankDeposit(a ,y , R);
62+
bd2.show();
63+
return 0;
64+
}
65+
66+
/*
67+
OutPut :
68+
69+
Enter the Value of a , y and i
70+
500
71+
1
72+
0.04
73+
74+
Principal amount was 500. Return value after 1 years is 520
75+
Enter the Value of a , y and i
76+
500
77+
1
78+
4
79+
80+
Principal amount was 500. Return value after 1 years is 520
81+
82+
*/

Divisble.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include<iostream>
2+
using namespace std ;
3+
4+
int main(){
5+
int a ;
6+
cout<<"Enter the No : ";
7+
cin>>a;
8+
if (a % 2 == 0){
9+
cout<<"The Number is Divisble";
10+
}
11+
else{
12+
cout<<"The Number is not Divisble";
13+
}
14+
return 0;
15+
}
16+
17+
/*
18+
OutPut :
19+
20+
Enter the No : 5
21+
The Number is not Divisble
22+
23+
*/

0 commit comments

Comments
 (0)