Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fcfae03

Browse files
committed
Update Lab 01
1 parent 537ac76 commit fcfae03

13 files changed

+133
-48
lines changed

‎Lab_01/01_hello_world.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Program to print text on the console.
2+
// cout -> console output.
3+
4+
#include <iostream>
5+
6+
using namespace std;
7+
8+
int main()
9+
{
10+
cout << "Hello, World!" << endl;
11+
system("pause");
12+
return 0;
13+
}

‎Lab_01/02_take_user_input.cpp‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Program to print an integer entered by the user.
2+
// cin -> console input.
3+
4+
#include <iostream>
5+
6+
using namespace std;
7+
8+
int main()
9+
{
10+
int number;
11+
cout << "Enter an integer: ";
12+
cin >> number;
13+
cout << "You entered: " << number << endl;
14+
system("pause");
15+
return 0;
16+
}

‎Lab_01/03_integer_operations.cpp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Program to Add/Subtract/Multiply/Divide Two Integers.
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
int main()
8+
{
9+
int num1, num2;
10+
cout << "Enter two integers: ";
11+
cin >> num1 >> num2;
12+
cout << "Sum: " << num1 + num2 << endl;
13+
cout << "Difference: " << num1 - num2 << endl;
14+
cout << "Product: " << num1 * num2 << endl;
15+
cout << "Quotient: " << num1 / num2 << endl;
16+
cout << "Remainder: " << num1 % num2 << endl;
17+
system("pause");
18+
return 0;
19+
}

‎Lab_01/04_integer_operations_v2.cpp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// C++ Program to Add/Subtract/Multiply/Divide Two Integers entered by the user.
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
int main()
8+
{
9+
int num1, num2;
10+
cout << "Enter two integers: ";
11+
cin >> num1 >> num2;
12+
cout << "Sum: " << num1 + num2 << endl;
13+
cout << "Difference: " << num1 - num2 << endl;
14+
cout << "Product: " << num1 * num2 << endl;
15+
cout << "Quotient: " << num1 / num2 << endl;
16+
cout << "Remainder: " << num1 % num2 << endl;
17+
system("pause");
18+
return 0;
19+
}

‎Lab_01/06_division.cpp‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// C++ Program to Compute Quotient and Remainder.
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
int main()
8+
{
9+
int dividend, divisor, quotient, remainder;
10+
cout << "Enter dividend: ";
11+
cin >> dividend;
12+
cout << "Enter divisor: ";
13+
cin >> divisor;
14+
quotient = dividend / divisor;
15+
remainder = dividend % divisor;
16+
cout << "Quotient = " << quotient << endl;
17+
cout << "Remainder = " << remainder << endl;
18+
system("pause");
19+
return 0;
20+
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Rustam Zokirov
2-
// C++ program to Calculate Area and Circumference of Circle
1+
// C++ program to Calculate Area and Circumference of Circle.
32

43
#include <iostream>
54

@@ -11,17 +10,17 @@ int main()
1110
float R, Area, Circumference;
1211
cout << "Please enter the Radius of Circle: ";
1312
cin >> R;
14-
if (R > 0)
15-
{
13+
14+
if (R > 0) {
1615
Area = 3.14 * R * R;
1716
Circumference = 2 * 3.14 * R;
1817
cout << "Area of Circle is " << Area << ";" << endl;
1918
cout << "Circumference of Circle is " << Circumference << ";" << endl;
2019
}
21-
else
22-
{
20+
else {
2321
cout << "Negative numbers cannot be applied !!!" << endl;
2422
}
23+
2524
system("pause");
2625
return 0;
2726
}
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Rustam Zokirov
2-
// C++ program to Calculate Area of Scalene Triangle
1+
// C++ program to Calculate Area of Scalene Triangle.
32

43
#include <iostream>
54
#include <math.h>
@@ -16,25 +15,23 @@ int main()
1615
cin >> b;
1716
cout << "Please enter the values for the third side of Triangle: ";
1817
cin >> c;
19-
if (a > 0 && b > 0 && c > 0)
20-
{
21-
if (c < a + b && a < b + c && b < a + c)
22-
{
18+
19+
if (a > 0 && b > 0 && c > 0) {
20+
if (c < a + b && a < b + c && b < a + c) {
2321
S = (a + b + c) / 2;
2422
Area = sqrt(S * (S - a) * (S - b) * (S - c));
2523
cout << "The Area of Triangle is " << Area << endl;
2624
return 0;
2725
}
28-
else
29-
{
26+
else {
3027
cout << "This triangle is wrong try another values." << endl;
3128
return 0;
3229
}
3330
}
34-
else
35-
{
31+
else {
3632
cout << "The sides of Triangle cannot be negative numbers!" << endl;
3733
}
34+
3835
system("pause");
3936
return 0;
4037
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Rustam Zokirov
2-
// C++ program to Calculate Area of Equilateral Triangle
1+
// C++ program to Calculate Area of Equilateral Triangle.
32

43
#include <iostream>
54
#include <math.h>
@@ -12,15 +11,15 @@ int main()
1211
float a, Area;
1312
cout << "Please enter the value for the side of Triangle: ";
1413
cin >> a;
15-
if (a > 0)
16-
{
14+
15+
if (a > 0) {
1716
Area = sqrt(2) * a * a * 0.25;
1817
cout << "The Area of this triangle is " << Area << ";" << endl;
1918
}
20-
else
21-
{
19+
else {
2220
cout << "The sides of Triangle cannot be negative numbers ! " << endl;
2321
}
22+
2423
system("pause");
2524
return 0;
2625
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Rustam Zokirov
2-
// C++ program to Calculate Area of Right angle Triangle
1+
// C++ program to Calculate Area of Right angle Triangle.
32

43
#include <iostream>
54

@@ -13,15 +12,15 @@ int main()
1312
cin >> a;
1413
cout << "Please enter the value for the second cathet of Triangle: ";
1514
cin >> b;
16-
if (a > 0 && b > 0)
17-
{
15+
16+
if (a > 0 && b > 0) {
1817
Area = b * a * 0.5;
1918
cout << "The Area of this Triangle is " << Area << ";" << endl;
2019
}
21-
else
22-
{
20+
else {
2321
cout << "The sides of Triangle cannot be negative numbers ! " << endl;
2422
}
23+
2524
system("pause");
2625
return 0;
2726
}

‎OOP1-Lab1/Rectangle.cpp‎ renamed to ‎Lab_01/11_rectangle.cpp‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Rustam Zokirov
2-
// C++ program to Calculate Area of Rectangle
1+
// C++ program to Calculate Area of Rectangle.
32

43
#include <iostream>
54
#include <math.h>
@@ -14,15 +13,15 @@ int main()
1413
cin >> a;
1514
cout << "Please enter the width of Rectangle: ";
1615
cin >> b;
17-
if (a > 0 && b > 0)
18-
{
16+
17+
if (a > 0 && b > 0) {
1918
Area = a * b;
2019
cout << "The area of Rectangle is " << Area << ";" << endl;
2120
}
22-
else
23-
{
21+
else {
2422
cout << "The sides of Rectangle cannot be negative numbers !" << endl;
2523
}
24+
2625
system("pause");
2726
return 0;
2827
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /