Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

program to be answered in C. please paste the code, thanks! CS 153 Program 3 - Sums (easy loop practice) 1. Write a pure function

image text in transcribed

program to be answered in C. please paste the code, thanks!

CS 153 Program 3 - Sums (easy loop practice) 1. Write a pure function int sumeloop int Ni that computes sum of Integers from 1 to N: Sum - 1+2+3+4+...+(n-1)+N Do this the obvious way by initializing a sum to zero and then adding up the integers using a loop. Now write a pure function int suformulatint that uses the familiar formula to compute the same thing. ( +1) 2. Now write a pure function sun Squaresloopfint sumn for integers 1 to N: that computes the Sum=1+2+3+ +(n-1)+n? Do this the obvious way by initializing a sum to zero and then adding up the squares of integers using a loop. that uses the Now write a pure function int sumquaresformulatint formula to compute the same thing. (x + 1)(2+1) 3. Now write a pure function sunCubesloop(int n) that computes the sum n' for integers 1 to N: Sum=1+2+3+...+(n-1)+n? Do this the obvious way by initializing a sum to zero and then adding up the cubes of integers using a loop. that uses the Now write a pure function int sumCubesformula(int N formula to compute the same thing. 4. Write a main function that asks the user for N, and then prints out six Sums as computed by each of the above six functions. Of course, the corresponding pairs should compute the same value. Do all I/O in main The functions themselves should not do I/O. Don't do error checking. Just let overflow happen for large N. C:\Source Enter N->75 sum I to N loopt 2850, formula: 2850 loop: 143450; formula 143450 su 1 to 3 loop: 8122500) formulat 8122500 C:Source Use ANSI-C syntax. Compile and run using the goc environment. Do not mix tabs and spaces in the source file. Debug thoroughly. Turn in a complete source file using Blackboard

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

ISBN: 0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Distinguish between product and period costs. AppendixLO1

Answered: 1 week ago