#beginner assignment won't allow for birth year user input

38 messages · Page 1 of 1 (latest)

acoustic mesa
#

No errors are shown on Microsoft visual, attempted to use ChatGPT to find an error and it didn't help. When running the code it allows for name input but not for age input, it automatically inputs 0:

Enter full name: Nick
Input birth year: 0 you are 858995483 years old!

..................

// 2023.08.27
// HW 2: Age Calculator
#include <iostream>
#include <string>
using namespace std;

int main()
{
string name;
int birthYear, currYear, age;
currYear = 2023;

cout << "Enter full name: ";  
cin >> name;        
cout << "Input birth year: ";        
cin >> birthYear;                
age = currYear - birthYear;
cout << name << " you are " << age << " years old!";

return 0;

}

potent pilotBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

oblique flax
acoustic mesa
oblique flax
#

sorry

#

i meant currYear

acoustic mesa
#

do i need to? i set the current year to 2023

glass swift
#

works on my machine though

#

hm

oblique flax
#

i gues not

acoustic mesa
glass swift
acoustic mesa
#

im going to install visual on my laptop and see if it works on that

oblique flax
#

it also works for me

glass swift
#

how are you running your code?

acoustic mesa
#

i just press the run button on microsoft visual, im not very familiar with IDE programs

glass swift
#

visual studio?

acoustic mesa
#

yes

glass swift
#

did you make sure to save your file and stuff

acoustic mesa
#

yes

#

ive restarted it a couple times

#

and tried to use Replit, but it said it took too much CPU for Replit

oblique flax
#

???

glass swift
#

damn

#

simple IO is too much for the online editor kekw

oblique flax
#

nah im calling BS on that

acoustic mesa
#

my professor told us its preferrable to use visual studio so i only used it to try to run this one

#

im not sure where im having issues

glass swift
#

yeah I'm not exactly sure either

#

that's really odd

#

well if it's for an assignment

#

at least your code is correct

oblique flax
#

the code is indeed fine

acoustic mesa
#

ok, im going to try to run it on my laptop instead of my desktop and if im stilling having issues I will ask my teacher when we have class next

#

!solved