Question

In: Computer Science

Write a program that will print the whole numbers from a user-specified minimum to a user-specified...

Write a program that will print the whole numbers from a user-specified minimum to a user-specified maximum. Display the total amount of numbers printed.

Solutions

Expert Solution

Below is the C program to print whole number between minimum to maximum range provided by user. and total amount of numbers printed.

Both minimum and maximun numbers are inclusive

#include <stdio.h>

int main()
{
    int minNumber, maxNumber, i;
    int totalNumberPrinted = 0;
    printf("Enter minimun number : ");
    scanf("%d", &minNumber);
    printf("Enter maximum number : ");
    scanf("%d", &maxNumber);
    
    //this minimun number and maximum number both inclusive
    for (i = minNumber; i<= maxNumber; i++) {
        printf("\n%d ",i);
        totalNumberPrinted++;
    }
    printf("\nTotal numbers printed are : %d", totalNumberPrinted);
    return 0;
}

Below is the output screenshot

Here assuming that user will give postive integers only as a input and maximun input number is greater than minimum number.


Related Solutions

write a java program that takes three numbers from the user and print the greatest number...
write a java program that takes three numbers from the user and print the greatest number (using if-statement). sample output: input the first number:35 input the second number:28 input the third number:87 the greatest number:87
1: Answer these questions: (a) Write a Java program to print whole numbers between 1 to...
1: Answer these questions: (a) Write a Java program to print whole numbers between 1 to 1000 which are divisible by 3, 5 and by both numbers. (b) Differentiate between instance and local variable in Java (c) In a tabular form, differentiate between instance and class variable
how to write a cpp program that takes a number from a user, and print the...
how to write a cpp program that takes a number from a user, and print the sum of all numbers from one to that number on screen? using loop interation as basic as possible.
Write a C++ program that reads numbers from the user until the user enters a Sentinel....
Write a C++ program that reads numbers from the user until the user enters a Sentinel. Use a Sentinel of -999. Ignore all negative numbers from the user input. Do the following: Output the sum of all even numbers Output the sum of all odd numbers Output the count of all even numbers Output the count of all odd numbers You must use loops and numbers to do this. You must not use any arrays or vectors for this program.
C++ Write a whole program to read 50 salaries from the file “Salaries.txt” and print them...
C++ Write a whole program to read 50 salaries from the file “Salaries.txt” and print them on the screen (each value on a separate line), you have to also save the grades (each value on a separate line) into another file “SalariesWithBonus.txt” after you add a bonus of two percent to each salary (example For the salary 100000 a bonus of 2000 will be added as 100000 X 0.02 = 2000). Your code should check whether the file “Salaries.txt” opened...
USE PYTHON. Create a program that will ask a user to enter whole positive numbers. The...
USE PYTHON. Create a program that will ask a user to enter whole positive numbers. The program will use a while loop to let the program keep running. The user will be allowed to use the program as long as the quitVariable is equal to 'y' or 'Y'. When the user decides to quit playing, say "Thanks for playing!". The program will use a for loop to test if the number are even or odd. If even print "number is...
IN JAVA Write a complete program that asks the user to enter two real numbers from...
IN JAVA Write a complete program that asks the user to enter two real numbers from the console. If both numbers are positive print the product, if both numbers are negative print the quotient, otherwise print INVALID INPUT. Use a nested if; output should be to a dialog and console; use printf to format the console output (for real numbers specify the width and number of digits after the decimal). The output must be labeled. Follow Java conventions, indent your...
Using MatLab Write a program which will: a. Accept two numbers from the user m and...
Using MatLab Write a program which will: a. Accept two numbers from the user m and n b. Define an array with the dimensions a(n,m) and fill it with random numbers in the range of -100 to 100 inclusive. c. Accept from the user two row numbers. Multiply the two rows (element by element) and find the sum. Print the result. d. Accept from the user two column numbers. Add the two columns (element by element) and find the sum....
Write a C program that prompt the user to enter 10 numbers andstores the numbers...
Write a C program that prompt the user to enter 10 numbers and stores the numbers in an array. Write a function, smallestIndex, that takes as parameters an int array and its size and return the index of the first occurrence of the smallest element in the array.The main function should print the smallest number and the index of the smallest number.
Write a C++ program that prompt the user to enter 10 numbers andstores the numbers...
Write a C++ program that prompt the user to enter 10 numbers and stores the numbers in an array. Write a function, smallestIndex, that takes as parameters an int array and its size and return the index of the first occurrence of the smallest element in the array.The main function should print the smallest number and the index of the smallest number.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT