Question
Using visualstudios C++ why wont the even and odd portion of my code run ? #include stdafx.h #include using namespace std; int main() { int
Using visualstudios C++
why wont the even and odd portion of my code run ?
#include "stdafx.h"
#include
using namespace std;
int main()
{
int somenumber;
int evennum, oddnum;
//newnumber;
cout << " Please enter some four digit integer that does not contain zeros." << endl;
cin >> somenumber;
while (somenumber <= 1000)
{
cout << " Invalid response. I will keep adding to your number until a new acceptable number is reached," << endl;
somenumber++;
cout << " The new number is :" << somenumber << endl;
}
if (somenumber > 1000 && somenumber < 9999)
{
int firstdigit = somenumber / 1000;
somenumber %= 1000;
int seconddigit = somenumber / 100;
somenumber %= 100;
int thirddigit = somenumber / 10;
int fourthdigit = somenumber % 10;
int newfirst = fourthdigit * 1000;
int newsecond = thirddigit * 100;
int newthird = seconddigit * 10;
int newfourth = firstdigit;
int reversednum = newfirst + newsecond + newthird + newfourth;
cout << "The new number is " << reversednum << endl;
}
if (somenumber % 2 == 0)
cin >> evennum;
if (somenumber % 1 == 0)
cin >> oddnum;
cout << oddnum << endl;
cout << evennum << endl;
//cout << "Would you like to input a new number? (Y/N)" << endl;
//cin >> response;
//f ( response == 'Y' || response =='y')
system("pause");
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started