Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Due: Before the beginning of the next lab . No late labs will be accepted . Please note that the assignment submission folder will be

Due: Before the beginning of the next lab . No late labs will be accepted.

Please note that the assignment submission folder will be unavailable after this time.

All your programs must include a Programmers Block and an explainProg function.

Format for the Programmers Block:

Description:

Programmer:

Date:

Version:

Output of all programs must be included with your code.

Using the following source file, from the debugger, create watch variables for

index, sum and number.

#include

#include

void square(int number);

int sum;

int main(void)

{

int index;

for (index = 1; index <= 7; index++)

square(index);

system("pause");

return(0);

}

void square(int number)

{

int numsq;

numsq = number * number;

sum = sum + numsq;

printf(" \t\t\tThe square of %d is %d ", number, numsq);

printf(" \t\t\tThe sum of the squares is %d ", sum);

return;

}

What does the watch window state about number when you are tracing outside the

function square()?

Why ( --- think of scope --- )?

What does the watch window state about index when you are tracing inside the

function square()?

Why ( --- think of scope --- )?

6) Modify the program as follows:

A) Make the global variable sum local to main() and make the program do exactly the

same thing.

Hint: return the square of the number from the function square() and do the summing

inside main() or initialize sum in main and pass it to square().

B) Make the global variable sum local to the function square(). Do the summing inside

the function.

Hint: Think about a static variable.

Submit both modified programs as well as the answers to parts 2 to 5

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

Explain why an economys output, in essence, is also its income.

Answered: 1 week ago

Question

What must a creditor do to become a secured party?

Answered: 1 week ago

Question

When should the last word in a title be capitalized?

Answered: 1 week ago

Question

7. Senior management supports the career system.

Answered: 1 week ago