This need to be done with c++ You have been given the task of designing a progra
ID: 3768768 • Letter: T
Question
This need to be done with c++ You have been given the task of designing a program to input two numbers (numi & mini2) and count from 1 to nunil incrementing by num2. Assume that numi and num2 arc positive integers.for example, if 10 and 2 are entered, your program will count starting from 1 to 10, every 2 numbers: 1 3 5 7 9 Output the numbers entered on one line and output of the count on the second line. Counting to: 10 Increment by: 2 Output: 1 3 5 7 9 Total up the numbers counted in a variable called numTotal. which should be the same data type as numi and num2. Total: 25 Your program must use a While or FOR loop for this assignment. Upload your C++ program into the Assignment area and submit when completed.Explanation / Answer
#include <iostream>
#include <conio.h>
using namespace std;
int main(){
int num1,num2,num_total=0,i;
cout << "Counting to: ";
cin >> num1;
cout << "Incemented by: ";
cin >> num2;
for(i=1;i<=num1;)
{ num_total=num_total+i;
cout<< i ;
i=i+num2;
}
cout<<endl;
cout << "Total: "<<num_total;
getch();
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.