Commit 4fa6bc4f authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'exe_06' into 'master'

Exercise_05_06 See merge request bpcarm/trainings2017!1211
parents 892fccf0 67e77ef9
exercise_05_06: main.o | .gitignore
g++ $^ -o $@
main.ii: main.cpp
g++ -E $^ -o $@
main.s: main.ii
g++ -S $^ -o $@
main.o: main.s
g++ -c $^ -o $@
.gitignore:
echo "exercise_05_06" > $@
clean:
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
.PRECIOUS: main.ii main.s
.SECONDARY: main.ii main.s
#include <iostream>
int
main()
{
int sum = 0;
std::cout << "Enter the numbers (9999 to exit): ";
int count = 0;
for ( ; ; ++count) {
int number;
std::cin >> number;
if (9999 == number) {
break;
}
sum += number;
}
double average = sum / count;
std::cout << "Average is " << average << std::endl;
return 0;
}
Enter the numbers (9999 to exit): Average is 42
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