Commit 82422530 authored by Believer Programmers' Club's avatar Believer Programmers' Club

Merge branch 'exercise_05_06' into 'master'

Mary Zaqaryan Exercise_05_06 Version 1 See merge request bpcarm/trainings2017!1301
parents 0be65a55 a82c1c87
#include <iostream>
int
main()
{
int sum = 0;
int counter = 0;
while (true) {
int number;
std::cout << "Enter the number (9999 to quit): ";
std::cin >> number;
if (9999 == number) {
break;
}
sum += number;
++counter;
}
double sequence = static_cast<double>(sum);
double average = sequence / counter;
std::cout << "Average is: " << average << std::endl;
return 0;
}
exercise_05_06: exercise_05_06.o | .gitignore
g++ $^ -o $@
exercise_05_06.ii: exercise_05_06.cpp
g++ -E $^ -o $@
exercise_05_06.s: exercise_05_06.ii
g++ -S $^ -o $@
exercise_05_06.o: exercise_05_06.s
g++ -c $^ -o $@
.gitignore:
echo "exercise_05_06" > $@
removes:
rm *.ii *.s *.o *.out exercise_05_06 .gitignore
test: exercise_05_06
./exercise_05_06 < test.in > test.out
diff test.out test.expected > /dev/null 2>&1 && echo PASSED || echo FAILED
Enter the number (9999 to quit): Enter the number (9999 to quit): Enter the number (9999 to quit): Enter the number (9999 to quit): Enter the number (9999 to quit): Enter the number (9999 to quit): Average is: 9.2
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