Question: C++ I need help fixing a part of my code, which is that if the number they inputed ends with a 1 2, 3 it

C++

I need help fixing a part of my code, which is that if the number they inputed ends with a 1 2, 3 it has to have a different ending compared to the rest of the numbers. Ex (1) : 1001st , Ex(2) 1002nd , Ex(3) 1003rd, Ex(4) 1004th.I can't figure out how to make this happen.This is my current code:

Code:

#include #include

using namespace std;

/* * */

int numberPattern(int x){ if(x == 1){ return 1; }else{

return (x*x) + numberPattern((x-1)); } }

int main() { cout << "The first four numbers in the pattern: "<= 4){ cout<<"\t"<> order; if(order == 0){ cout<< " GOOD BYE!"<< endl; cout <<"Programmer: Francisco Gallego - written for the class CISC 192/C++ Programming."; cin.ignore(); cout <<" Press Enter to Exit..."; cin.get(); break; } if(numberPattern(order) >=1){ cout<<"The "<< order<<"th element is: "<< numberPattern(order)<< endl; } else{ cout << " NOTE: The large value entered will make stack overflow."<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!