Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started