Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 5(5 points): Create a C-C++ program that will Ask the user for and a nu

ID: 3841590 • Letter: Q

Question

QUESTION 5(5 points): Create a C-C++ program that will Ask the user for and a number from the user. The number must be an integer and greater th to 2 and less than 10. If a number that does not meet the specification, the user must be reprom until they provide a valid number. Generate console output (see example below) output from where a series of integer is rand counting down. The output must not include any values User nun greater than the user provided number or less than 1. The numbers must follow the pattem where: o Even numbers are output only once. o odd numbers are output based on the value of the number. ie 3 is output 3 times while 5 output 5 times Example If user enters 6 for number, output would be: 655555433321 Your program must process one valid number from the user and then end Remember crib sheet has functions that you may want to use. Declare any variables you need

Explanation / Answer

Code :-

#include <iostream>
using namespace std;

int main() {
   int check = 0;
   int num;
   while(1){
   cout<<"Enter a number in the range 2<= x and x<10 "<<endl;
   cin>>num;
   if(num>= 2 && num < 10){
   for(int i =num;i>0;i--){
   if(i % 2 == 0){
   cout<<i;
   }
   else{
   for(int j=i;j>0;j--){
   cout<<i;
   }
   }
   }
   check=1;
   }
   if(check == 0){
   cout<<"INPUT DOESn'T MATCH THE condition..Please try again "<<endl;
   }
   else
   break;
   }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote