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...

  • 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....

  • 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...

  • in java PART ONE ================================================== Write a program that will read employee earnings data from an...

    in java PART ONE ================================================== Write a program that will read employee earnings data from an external file and then sort and display that data. Copy and paste the input file data below into an external file, which your program will then read. You will want to use parallel arrays for this program. Modify the select sort algorithm to receive both arrays as parameters as well as the size of the arrays. Use the algorithm to sort your earnings array....

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

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
ADVERTISEMENT