Question: Part 1: Global variables in C Write a C program where you declare and initialize two global integer variables A and B. Write a function
Part 1: Global variables in C
Write a C program where you declare and initialize two global integer variables A and B. Write a
function whatPercentage( ) that calculates the percentage of B that A represents. The function
whatPercentage( ) does not take any input parameters and returns the result of an expression
containing A and B.
In the main( ) body of your program, write the following in this exact logical order:
1. Invoke whatPercentage( ) and print its result.
2. Assign new values to A and B.
3. Invoke whatPercentage( ) again and print its result.
4. Add a comment to your code that precisely states what differences you observed in the
two invocations of the function, and to what concept would you attribute this behavior.
5. To the global declaration of A and B, add the keyword const as const int A = 1. What
happens when you run your program now. Add a comment to your code that states your
observations for this part. Please comment out the keyword const when you submit your
code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
