Create a counting program that prompts the user for 3 inputs (shown next) that d
ID: 640959 • Letter: C
Question
Create a counting program that prompts the user for 3 inputs (shown next) that determine how and what to count. Store the user's answers in veriables. Use the acquired data to build your counting program with a for loop and display the results to the user.
1)Beginning number to start counting from
2) Ending number to stop counting at
3) Increment number
**This is what I have but it keeps kicking me out after I input the values.
#include
#include
main()
{
//Call variables
int iBegin=0;
int iEnd=0;
int iIncrement=0;
int x=0;
int y=1;
//Assign variables
printf(" Please input a number to begin counting: ");
scanf("%d", &iBegin);
printf("Please input a number to stop counting: ");
scanf("%d", &iEnd);
printf("Please input the amount you want to count by: ");
scanf("%d", iIncrement);
//for loop
for ( x = iBegin; x < iEnd; x=y++ * iIncrement )
printf("%d", x);
}
Explanation / Answer
#include <stdio.h>
#include <ctype.h>
main()
{
//Call variables
int iBegin = 0;
int iEnd = 0;
int iIncrement = 0;
int x = 0;
int y = 1;
//Assign variables
printf(" Please input a number to begin counting: ");
scanf("%d", &iBegin);
printf("Please input a number to stop counting: ");
scanf("%d", &iEnd);
printf("Please input the amount you want to count by: ");
scanf("%d", &iIncrement);
//for loop
for (x = iBegin; x < iEnd; x += iIncrement)
printf("%d ", x);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.