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
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: "<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
