Question


p unugil pairs of tiput Values until the user enters nonnumeric input. Modify exercise 7 so that it uses a function to return the value of the calculation. Write a program that requests lower and upper integer limits, calculates the sum of all the integer S: uares from the square of the lower limit to the square of the upper limit, and displays the answer. The program should then continue to prompt for limits and display answers until enters an upper limit that is equal to or less than the lower limit. A sample run should look something like this sq the user Enter lower and upper integer limits: 5 9 The sums of the squares from 25 to 81 is 255 Enter next set of limits: 3 25 The sums of the squares from 9 to 625 is 5520 Enter next set of limits: 5 5 20


please send me within 15 mins if possible

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>
int main(void)
{
int index, lower, upper, square, total, input;
printf("Enter lower and upper integer limits: ");
for (input = scanf("%d %d", &lower, &upper); input == 2; printf("Enter the next set of limits: \n"), scanf("%d %d", &lower, &upper))
{
for (index = lower; index <= upper; index++)
{
square = index * index;
total += square;
}
printf("The sums of the squares from %d to %d is %d\n", lower * lower, upper * upper, total);
}
return 0;
}
int main(void)
{
int index, lower, upper, square, total;
printf("Enter lower and upper integer limits: ");
while (scanf("%d %d", &lower, &upper) == 2)
{
total = 0;
for (index = lower; upper > index; index++)
{
square = index * index;
total += square;
}
printf("The sums of the squares from %d to %d is %d\n", lower * lower, upper * upper, total);
printf("Enter the next set of limits: \n");
}
return 0;
}
UPDATE*****
Thanks to everyone's help I think I finally got it:
include
int main(void)
{
int index, lower, upper, square, total;
printf("Enter lower and upper integer limits: ");
while (scanf("%d %d", &lower, &upper) == 2)
{
while (lower < upper)
{
total = 0;
for (index = lower; index <= upper; index++)
{
square = index * index;
total += square;
}
printf("The sums of the squares from %d to %d is %d\n", lower * lower, upper * upper, total);
printf("Enter the next set of limits: \n");
scanf("%d %d", &lower, &upper);
}
printf("Done");
}
return 0;

}

int index, lower, upper, square, total, input;
while(1)
{
total = 0;
printf("Enter lower and upper integer limits: ");
fflush(stdout);
input = scanf("%d %d", &lower, &upper);
if(input != 2) continue;
if(upper <= lower) break;
for (index = lower; index <= upper; index++)
{
square = index * index;
total += square;
}
printf("The sums of the squares from %d to %d is %d\n", lower , upper, total );
}
printf("Done\n");
Add a comment
Know the answer?
Add Answer to:
please send me within 15 mins if possible p unugil pairs of tiput Values until the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program to sum up all the odd numbers between a lower limit number...

    Write a C program to sum up all the odd numbers between a lower limit number and an upper limit number provided by a user. The requirements are: First, request the user to provide a lower limit integer number and an upper limit integer number that is larger than the lower limit number, and save them in variables lowerLimit and upperLimit, respectively. If the user has entered an upper limit number (upper Limit) that is NOT larger than the lower...

  • Please assist with the hw assignment..thank you! MATH 101 HW ASSIGNMENT Due Jan 25, 2019 Frequency...

    Please assist with the hw assignment..thank you! MATH 101 HW ASSIGNMENT Due Jan 25, 2019 Frequency Distributions A set of samples from a population measuring some characteristic of the group organized into a table Range Max. Value-Min. Value The distribution of data values are classified into several groups (or Classes) Class Width distance between the lower limit of one class and lower limit of the next higher class. Class Width (also) distance between upper limit of one class and the...

  • This assignment requires you to write a program to implement an odd-order Magic Square. Prompt the...

    This assignment requires you to write a program to implement an odd-order Magic Square. Prompt the user to enter the “order” of the square and then produce for the user a magic square of that order. Run your code for at least four different inputs – all odd. ODD ORDER MAGIC SQUARES 1. Start by placing 1 in the middle column of the top row. 2. Continue by always placing the next number (say k+1) in the square diagonally up...

  • please help me out and input values please .. main cpp.. please follow intructions exactly witj...

    please help me out and input values please .. main cpp.. please follow intructions exactly witj clarity please CSE 110-Intro to Computer Programming Project #3 Requirements-String Class Functions and Test Case Documentation Using the String Class, design and develop a multi-file password validation program and Test case Document (10% of grade) that requests a password, and validates it based on the following criteria. The password must be at least 8 characters long, contain at least one number, and at least...

  • Can someone please help me with how to write this in Java? You will write a...

    Can someone please help me with how to write this in Java? You will write a program to evaluate a math expression given by a user. • Read the input from the scanner • Expressions should match the forms below. Note that you will need spaces between the numbers and operators for your scanner methods to work best. - “number1 operator number2” - “operator number1” • Declare number1 and number2 as type integer. Test using integer values. • You must...

  • Assignment Draw a flowchart, using Microsoft Visio or LucidChart, to document the logic required to complete...

    Assignment Draw a flowchart, using Microsoft Visio or LucidChart, to document the logic required to complete this program Save the flowchart as a PDF file Develop a C++ program, following the logic in your flowchart, to convert a series of whole number decimal values to their Roman equivalent. Develop a function that will accept a whole number value in the range 1-9999 and return a string containing the long-form Roman Numeral equivalent of the input value, consisting only of upper-case...

  • What is the java code for this. The goal of this lab is to write two...

    What is the java code for this. The goal of this lab is to write two programs, Summation and Prime, that execute simple tasks. The first computes the summation of integers within a range with a gap that the user specifies. The second tests whether the integer that the user enters is a square and if not, whether it is composite or prime. Summation Let us see some execution examples first, to get the sense of how the program works....

  • PART TWO Write a program which will populate an integer ArrayList with user input, and then...

    PART TWO Write a program which will populate an integer ArrayList with user input, and then provide a menu of various operations to perform on that ArrayList. The first step is to have the user push a bunch of integers into a ArrayList. The second step is to perform various operations on that ArrayList. Your input must be in the format below. The user can enter either a positive integer or -99 to quit. The menu to present is: Sum...

  • JAVA, please You must write a robust program meaning that your program should not crash with...

    JAVA, please You must write a robust program meaning that your program should not crash with any given data. Data validation must be done any time that user enters an input. Write a program that 1. Gets an infix expression form the user and evaluate the expression using stack ADT a. Finds the postfix equivalent of the given infix expression b. Evaluate the created postfix expression. c. Note: your program should not crash when you enter an invalid expression such...

  • In C please : The tasks in this exam review exercise are structured in levels. You...

    In C please : The tasks in this exam review exercise are structured in levels. You can see the point distribution for the levels at the end. It is strongly recommended that you ensure you have passed all test cases of lower levels before moving up to a higher level. For example, ensure you have completed all Level 0 and 1 tasks before even looking at Level 2 Tasks. MESSAGE ENCODER LEVEL 0: (test cases - 50 points) Start by...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT