Skip to content

Commit 33a5713

Browse files
initial
0 parents  commit 33a5713

Some content is hidden

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

64 files changed

+2032
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.exe
2+
*.png
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include <iostream>
2+
#include <conio.h>
3+
using namespace std;
4+
5+
class complex
6+
{
7+
private:
8+
int a,b;
9+
public:
10+
void setdata(int x, int y)
11+
{
12+
a=x;
13+
b=y;
14+
}
15+
void showdata()
16+
{
17+
cout<<a<<"+"<<b<<"i"<<"\n\n";
18+
}
19+
20+
complex add(complex X)
21+
{
22+
complex temp;
23+
temp.a=a+ X.a;
24+
temp.b=b+ X.b;
25+
return temp;
26+
}
27+
complex sub(complex X)
28+
{
29+
complex temp;
30+
temp.a=a- X.a;
31+
temp.b=b- X.b;
32+
return temp;
33+
}
34+
complex multi(complex X)
35+
{
36+
complex temp;
37+
temp.a=a* X.a;
38+
temp.b=b* X.b;
39+
return temp;
40+
}
41+
};
42+
43+
int main()
44+
{
45+
complex c1,c2, c3, c4, c5;
46+
47+
c1.setdata(3,4);
48+
c2.setdata(5,6);
49+
50+
c1.showdata();
51+
c2.showdata();
52+
53+
c3=c1.add(c2);
54+
c3.showdata();
55+
56+
57+
c4=c1.sub(c2);
58+
c4.showdata();
59+
60+
61+
c5=c1.multi(c2);
62+
c5.showdata();
63+
64+
getch();
65+
return 0;
66+
}

Class & objects/add_two_time.cpp

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <iostream>
2+
#include <conio.h>
3+
using namespace std;
4+
5+
class time
6+
{
7+
private:
8+
int HR, MIN, SEC;
9+
10+
public:
11+
void set_time(int, int, int);
12+
void show_time();
13+
time add_time(time X);
14+
};
15+
16+
void time::set_time(int hr, int min, int sec)
17+
{
18+
HR = hr;
19+
MIN = min;
20+
SEC = sec;
21+
}
22+
void time::show_time()
23+
{
24+
cout << HR << ":" << MIN << ":" << SEC << endl;
25+
}
26+
27+
time time::add_time(time X)
28+
{
29+
time temp;
30+
31+
temp.SEC = SEC + X.SEC;
32+
temp.MIN = MIN + X.MIN + temp.SEC / 60;
33+
temp.SEC = temp.SEC % 60;
34+
35+
temp.HR = HR + X.HR + temp.MIN / 60;
36+
temp.MIN = temp.MIN % 60;
37+
return temp;
38+
}
39+
40+
int main()
41+
{
42+
time t1, t2, t3;
43+
t1.set_time(3, 40, 50);
44+
t1.show_time();
45+
t2.set_time(2, 10, 55);
46+
t2.show_time();
47+
48+
t3 = t1.add_time(t2);
49+
t3.show_time();
50+
return 0;
51+
}

Class & objects/assign1.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
#include <conio.h>
3+
using namespace std;
4+
5+
class complex
6+
{
7+
private:
8+
int a,b;
9+
public:
10+
void setdata(int x, int y)
11+
{
12+
a=x;
13+
b=y;
14+
}
15+
void showdata()
16+
{
17+
cout<<a<<"+"<<b<<"i"<<"\n";
18+
}
19+
20+
complex add(complex X)
21+
{
22+
complex temp;
23+
temp.a=a+X.a;
24+
temp.b=b+X.b;
25+
return temp;
26+
}
27+
};
28+
29+
int main()
30+
{
31+
complex c1,c2,c3;
32+
33+
c1.setdata(3,5);
34+
c2.setdata(6,10);
35+
36+
c1.showdata();
37+
c2.showdata();
38+
39+
c3=c1.add(c2);
40+
c3.showdata();
41+
getch();
42+
return 0;
43+
}

Class & objects/assign2.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <iostream>
2+
#include <conio.h>
3+
using namespace std;
4+
5+
class time
6+
{
7+
private:
8+
int HR, MIN, SEC;
9+
public:
10+
void set_time(int,int,int);
11+
void show_time();
12+
void normalize();
13+
};
14+
15+
void time::set_time(int hr, int min, int sec)
16+
{
17+
HR=hr;
18+
MIN=min;
19+
SEC=sec;
20+
}
21+
void time::show_time()
22+
{
23+
cout<<"\n"<<HR<<":"<<MIN<<":"<<SEC<<endl;
24+
}
25+
void time::normalize()
26+
{
27+
MIN=MIN+SEC/60;
28+
SEC=SEC%60;
29+
HR=HR+MIN/60;
30+
MIN=MIN%60;
31+
}
32+
33+
int main()
34+
{
35+
time t1;
36+
t1.set_time(3,45,70);
37+
t1.show_time();
38+
t1.normalize();
39+
t1.show_time();
40+
return 0;
41+
}

Class & objects/complex.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <iostream>
2+
#include <conio.h>
3+
using namespace std;
4+
5+
class complex
6+
{
7+
private:
8+
int a,b;
9+
public:
10+
void setdata(int x, int y)
11+
{
12+
a=x,b=y;
13+
}
14+
void showdata()
15+
{
16+
cout<<a<<"+"<<b<<"i\n";
17+
}
18+
};
19+
20+
int main()
21+
{
22+
complex c1,c2;
23+
c1.setdata(3,4);
24+
c2.setdata(5,9);
25+
c1.showdata();
26+
c2.showdata();
27+
getch();
28+
return 0;
29+
}

Class & objects/time_class.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
class time
5+
{
6+
private:
7+
int HR, MIN, SEC;
8+
9+
public:
10+
void set_time(int hr, int min, int sec)
11+
{
12+
HR = hr;
13+
MIN = min;
14+
SEC = sec;
15+
}
16+
void show_time()
17+
{
18+
cout << HR << ":" << MIN << ":" << SEC << endl;
19+
}
20+
void normalize()
21+
{
22+
MIN = MIN + SEC / 60;
23+
HR = HR + MIN / 60;
24+
SEC = SEC % 60;
25+
MIN = MIN % 60;
26+
}
27+
};
28+
29+
int main()
30+
{
31+
time t1;
32+
t1.set_time(2, 40, 70);
33+
t1.show_time();
34+
t1.normalize();
35+
t1.show_time();
36+
return 0;
37+
}

Constructor/ex.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
class example
5+
{
6+
private:
7+
int a,b;
8+
public:
9+
10+
example()
11+
{
12+
a=0,b=0;
13+
}
14+
/*example(int x) parametrized constructor
15+
{
16+
a=x, b=0;
17+
}
18+
example(int x,int y)
19+
{
20+
a=x,b=y;
21+
}*/
22+
/*void set_data(int x,int y)
23+
{
24+
a=x,b=y;
25+
}*/
26+
void show_data()
27+
{
28+
cout<<"\na= "<<a<<" b= "<<b<<"\n";
29+
}
30+
};
31+
32+
int main()
33+
{
34+
example e1;
35+
e1.show_data();
36+
return 0;
37+
}

Decision_control/assign1.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <iostream>
2+
#include <conio.h>
3+
4+
int main()
5+
{
6+
int n;
7+
std::cout<<"Enter a number: ";
8+
std::cin>>n;
9+
10+
if(n%7==0)
11+
std::cout<<"Yes";
12+
else
13+
std::cout<<"No";
14+
getch();
15+
return 0;
16+
}

Decision_control/assign10.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <iostream>
2+
#include <conio.h>
3+
using namespace std;
4+
5+
int main()
6+
{
7+
char ch;
8+
cout<<"Enter a character: ";
9+
cin>>ch;
10+
11+
if(ch>='A' && ch<='Z')
12+
cout<<"uppercase alphabet";
13+
else if(ch>='a' && ch<='z')
14+
cout<<"lowercase alphabet";
15+
else if(ch=='@' || ch>='!' && ch<=')')
16+
cout<<"special character";
17+
else
18+
cout<<"digit";
19+
getch();
20+
return 0;
21+
}

Decision_control/assign2.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <iostream>
2+
#include <conio.h>
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int P,B,H;
8+
cout<<"Enter perpendicular, base and hypotenus: ";
9+
cin>>P>>B>>H;
10+
11+
int res;
12+
res=(P*P)+(B*B);
13+
if(res==(H*H))
14+
cout<<"Yes, it is Right angle triangle";
15+
else
16+
cout<<"Not a Right angle triangle";
17+
getch();
18+
return 0;
19+
}

0 commit comments

Comments
 (0)