149k views
1 vote
Write a flowchart and C code for a program that does the following: Within main(), it asks for the user's annual income. Within main(), it calls a function called printIt() and passes the income value to printIt(). The printIt() function evaluates the income, and if the number is over 90000, it prints a congratulatory message. If the income is not over 90000, it prints a message of encouragement, like "You WILL make $50,000, if you keep going."

User Ashouri
by
5.6k points

1 Answer

5 votes

Answer:

I am writing a C program:

#include <stdio.h> //to use input output functions

void printIt(double annual_in){ //function printIt

if(annual_in >90000) //check if the income is greater than 90000

printf("Congratulations. Doing great!"); //print this message if income value is greater than 90000

else //if annual income is less than 90000

printf("You WILL make $50,000, if you keep going"); } //print this message if income value is less than 90000

int main() //start of main() funciton body

{ double income; //declares a double type variable income to hold annual income value

printf("Enter annual income: "); //prompts user to enter annual income

scanf("%lf",&income); //reads income value from user

printIt(income); } // calls printIt method by passing input income to that function

Step-by-step explanation:

The program is well explained in the comments mentioned with each statement of the program. The flowchart is attached.

First flowchart flow1 has a separate main program flowchart which reads the income and calls printIt function. A second flowchart is of prinIt() method that checks the input income passed by main function and displays the corresponding messages and return.

The second flowchart flow2 is the simple flowchart that simply gives functional description of the C program as flowchart is not where giving function definitions is important. Instead of defining the function printIt separately for this C program, a high-level representation of functional aspects of this program is described in second flowchart while not getting into implementation details.

Write a flowchart and C code for a program that does the following: Within main(), it-example-1
Write a flowchart and C code for a program that does the following: Within main(), it-example-2
Write a flowchart and C code for a program that does the following: Within main(), it-example-3
User Pittnerf
by
5.6k points