Commit 50f49354 authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'exe_06_21' into 'master'

Exercise_06_21, Verson1 See merge request bpcarm/trainings2017!1247
parents 9913d26f 6f6b3dbf
progname = exercise_06_21
CC = g++
CFLAGS = -Wall -Wextra -Werror -g3
$(progname): $(progname).o | .gitignore
$(CC) $(CFLAGS) $^ -o $@
%.ii: %.cpp
$(CC) -E $(CFLAGS) $< -o $@
%.s: %.ii
$(CC) -S $(CFLAGS) $< -o $@
%.o: %.s
$(CC) -c $(CFLAGS) $< -o $@
.gitignore:
echo $(progname) > $@
clean:
rm -f *.ii *.s *.o *.out $(progname) .gitignore
test: $(progname)
./$(progname) < $@.in > $@.out
diff $@.out $@.expected && echo PASSED || echo FAILED
.PRECIOUS: $(progname).ii $(progname).s
.SECONDARY: $(progname).ii $(progname).s
#include <iostream>
bool
isEven(int x)
{
return x % 2 == 0;
}
int
main()
{
int count;
std::cout << "Enter the count of number: ";
std::cin >> count;
std::cout << std::endl;
for (int i = 1; i <= count; ++i) {
int number;
std::cout << "Enter a number to check: ";
std::cin >> number;
const bool result = isEven(number);
if (result) {
std::cout << number << "is even." << std::endl;
} else {
std::cout << number << "is odd." << std::endl;
}
}
return 0;
}
Enter the count of number:
Enter a number to check: 1is odd.
Enter a number to check: 2is even.
Enter a number to check: 3is odd.
Enter a number to check: 4is even.
Enter a number to check: 5is odd.
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