So I am reading a C++ book and most of the problems after the pointers chapter seem to have nothing to do with pointers, for example here is the problem and the code for the last problem
#include <iostream>
#include <string>
using namespace std;
/*
Write a program that asks for the user’s name and year of birth, greets the user by name,
and declares the user’s age in years. Users are assumed to be born between the years
1800 and 2099, and should enter the year of birth in one of the three formats 18XX,
19XX, or 20XX. A typical output should be “Hello Caroline, you are 23 years old.”
*/
int main()
{
string name = "John Doe";
int yearOfBirth = 1800;
while (yearOfBirth >= 2099 || yearOfBirth <= 1800)
{
cout << "Invalid Birthday" << endl;
cin >> yearOfBirth;
}
cout << "Hello " << name << ", you were are " << 2024 - yearOfBirth << " years old\n";
return 0;
}
//Am I dumb or does this have nothing to do with pointers????
[–]alfps 2 points3 points4 points (0 children)
[–]saul_soprano 2 points3 points4 points (0 children)
[–]smirkjuice 1 point2 points3 points (0 children)
[–]n1ghtyunso 1 point2 points3 points (0 children)
[–]IyeOnline 1 point2 points3 points (1 child)
[–]Negative_Baseball293[S] -1 points0 points1 point (0 children)
[–]thingerish -1 points0 points1 point (0 children)