Mariam Malkhasyan - Removed old exercises

parent 7b9d4d7f
#include <iostream>
int
main()
{
int number1;
int number2;
std::cout << "Enter first integer: ";
std::cin >> number1;
std::cout << "Enter second integer: ";
std::cin >> number2;
if (0 == number2) {
std::cout << "Error 1: Division by 0, because the denominator cannot be 0. " << std::endl;
return 1;
}
std::cout << number1 << " + " << number2 << " = " << (number1 + number2) << std::endl;
std::cout << number1 << " - " << number2 << " = " << (number1 - number2) << std::endl;
std::cout << number1 << " * " << number2 << " = " << (number1 * number2) << std::endl;
std::cout << number1 << " / " << number2 << " = " << (number1 / number2) << std::endl;
return 0;
}
Program:
g++ -E exercise_02_16.cpp -o exercise_02_16.ii
g++ -S exercise_02_16.ii -o exercise_02_16.s
g++ -c exercise_02_16.s -o exercise_02_16.o
g++ exercise_02_16.o -o exercise_02_16
echo exercise_02_16 > .gitignore
Cleanup:
rm exercise_02_16.ii exercise_02_16.s exercise_02_16.o exercise_02_16 .gitignore
Test:
./exercise_02_16
#include <iostream>
int
main()
{
std::cout << "1 2 3 4 \n"; /// a)
std::cout << "1 " << "2 " << "3 " << "4 \n"; /// b)
std::cout << "1 "; /// c)
std::cout << "2 ";
std::cout << "3 ";
std::cout << "4 " << std::endl;
return 0;
}
program:
g++ -E exercise_02_17.cpp -o exercise_02_17.ii
g++ -S exercise_02_17.ii -o exercise_02_17.s
g++ -c exercise_02_17.s -o exercise_02_17.o
g++ exercise_02_17.o -o exercise_02_17
echo exercise_02_17 > .gitignore
clean:
rm exercise_02_17.ii exercise_02_17.s exercise_02_17.o exercise_02_17 .gitignore
test:
./exercise_02_17
#include <iostream>
int
main()
{
int integer1, integer2;
std::cout << "Enter two integers: ";
std::cin >> integer1 >> integer2;
if (integer1 > integer2) {
std::cout << integer1 << " is larger." << std::endl;
return 0;
}
if (integer2 > integer1) {
std::cout << integer2 << " is larger." << std::endl;
return 0;
}
std::cout << "These numbers are equal." << std::endl;
return 0;
}
program:
g++ -E exercise_02_18.cpp -o exercise_02_18.ii
g++ -S exercise_02_18.ii -o exercise_02_18.s
g++ -c exercise_02_18.s -o exercise_02_18.o
g++ exercise_02_18.o -o exercise_02_18
echo exercise_02_18 > .gitignore
clean:
rm exercise_02_18.ii exercise_02_18.s exercise_02_18.o exercise_02_18 .gitignore
test:
./exercise_02_18
#include <iostream>
int
main()
{
std::cout << "••••••••• *** * *\n"
<< "* * * * *** * *\n"
<< "* * * * ***** * *\n"
<< "* * * * * * *\n"
<< "* * * * * * *\n"
<< "* * * * * * *\n"
<< "* * * * * * *\n"
<< "* * * * * * *\n"
<< "********* *** * *" << std::endl;
return 0;
}
Program:
g++ -E exercise_02_21.cpp -o exercise_02_21.ii
g++ -S exercise_02_21.ii -o exercise_02_21.s
g++ -c exercise_02_21.s -o exercise_02_21.o
g++ exercise_02_21.o -o exercise_02_21
echo exercise_02_21 > .gitignore
Clean:
rm exercise_02_21.ii exercise_02_21.s exercise_02_21.o exercise_02_21 .gitignore
Test:
./exercise_02_21
#include <iostream>
int
main()
{
int number1, number2, number3, number4, number5;
std::cout << "Enter 5 integers: ";
std::cin >> number1 >> number2 >> number3 >> number4 >> number5;
int small = number1;
if (number2 < small) {
number2 = small;
}
if (number3 < small) {
number3 = small;
}
if (number4 < small) {
number4 = small;
}
if (number5 < small) {
number5 = small;
}
std::cout << "Smallest number: " << small << std::endl;
int large = number5;
if (number4 > large) {
number4 = large;
}
if (number3 > large) {
number3 = large;
}
if (number2 > large) {
number2 = large;
}
if (number1 > large) {
number1 = large;
}
std::cout << "Largest number: " << large << std::endl;
return 0;
}
Program:
g++ -E exercise_02_23.cpp -o exercise_02_23.ii
g++ -S exercise_02_23.ii -o exercise_02_23.s
g++ -c exercise_02_23.s -o exercise_02_23.o
g++ exercise_02_23.o -o exercise_02_23
echo exercise_02_23 > .gitignore
Clean:
rm exercise_02_23.ii exercise_02_23.s exercise_02_23.o exercise_02_23 .gitignore
Test:
.exercise_02_23
#include <iostream>
int
main()
{
int number1, number2, number3;
std::cout << "Enter three numbers " << std::endl;
std::cin >> number1 >> number2 >> number3;
std::cout << "Sum is " << number1 + number2 + number3 << std::endl;
std::cout << "Average is " << (number1 + number2 + number3) / 3 << std::endl;
std::cout << "Product is " << number1 * number2 * number3 << std::endl;
///small
int small = number1;
if (number2 < small) {
small = number2;
}
if (number3 < small) {
small = number3;
}
std::cout << small << std::endl;
///large
int large = number1;
if (number2 > large) {
large = number2;
}
if (number3 > large) {
large = number3;
}
std::cout << large << std::endl;
return 0;
}
Program:
g++ -E exercise_2_19.cpp -o exercise_2_19.ii
g++ -S exercise_2_19.ii -o exercise_2_19.s
g++ -c exercise_2_19.o -o exercise_2_19.o
g++ exercise_2_19.o -o exercise_2_19
echo exercise_2_19 > .gitignore
Cleanup:
rm exercise_2_19.ii exercise_2_19.s exercise_2_19.o exercise_2_19 .gitignore
Test:
./exercise_2_19
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment