Assert Function -- please help

0 brenton leon · February 20, 2015
program to validate if someone is allowed to vote or not. The person who is allowed to vote should be at least 18 years old. The program should use the assert function to validate that the year of birth is not equal to the current year and also that the year of birth entered is not greater than the current year. The program should instruct the user to enter the year of birth.

Post a Reply


Oldest  Newest  Rating
0 brenton leon · February 20, 2015
Programming is all new to me ... thanks for the help
0 Mathias Frits Rørvik · February 20, 2015

#include <iostream>
#include <cassert>

int main()
const int currentYear = 2015;
int year;
std::cout << "Enter year of birth" << std::endl;
std::cin >> year;
assert(year < currentYear && (currentYear - year) >= 18);
return 0;

You now owe me 100 USD.
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator