The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Create a flowchart that matches the following C program:
Note: each function (module) should have its own specific flowchart.
Flowchart must be created using Visio
Â
Â
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*prototypes*/
void sum(int a, int b,int*);
void dif(int a, int b,int*);
void pro(int a, int b,int*);
void quo(int a, int b,int*);
void printMenu();
int main(void) /*begin program execution*/
{
int userSelect;
int a = 0, b = 0;
int result; //This will store the all result of operation
printf(
"Hello, Welcome to the Calculator Program! This program allows you to select a mode of operation and enter two numbers to apply this operation.");
userSelect = 0; /*menu selection*/
do {
printMenu();
//select operation
scanf("%d", &userSelect);
//selection1 for Addition
if (userSelect == 1) {
//This function will pass three variable a,b, and address of result
//so that result will result will be directly acces using call by refernce
sum(a, b,&result);
//will print the sum of two number
printf("Sum is:%dn", result);
}
//Substration
else if (userSelect == 2) {
//This function will pass three variable a,b, and address of result
//so that result will result will be directly acces using call by refernce
dif(a, b,&result);
//will print the substration of two number
printf("Difference is: %dn", result);
}
//Multiplication
else if (userSelect == 3) {
//This function will pass three variable a,b, and address of result
//so that result will result will be directly acces using call by refernce
pro(a, b,&result);
//will print the substration of two number
printf("Product is:%dn", result);
}
//Divide
else if (userSelect == 4) {
quo(a, b,&result);
//will print the substration of two number
printf("Quotient is:%dn", result);
}
} while (userSelect > 0 && userSelect <= 4); /*end do...while*/
return 0;
} /*end main*/
/***
* Print Menu
*/
void printMenu() {
printf(
"Menu:n 1.Additionn 2.Subtractionn 3.Multiplicationn 4. Divisionn");
}
/***
* Sum Function
*
*/
void sum(int a, int b,int *result) {
printf("Enter first number");
scanf("%d", &a);
printf("Enter second number");
scanf("%d", &b);
*result = (a + b);
}
/**
* Substraction function
*/
void dif(int a, int b,int *result) {
printf("Enter first number");
scanf("%d", &a);
printf("Enter second number");
scanf("%d", &b);
*result = (a - b);
}
/***
* Product of number
*/
void pro(int a, int b,int *result) {
printf("Enter first number");
scanf("%d", &a);
printf("Enter second number");
scanf("%d", &b);
*result = (a * b);
}
/***
* Division of two number
*/
void quo(int a, int b,int *result) {
printf("Enter first number");
scanf("%d", &a);
printf("Enter second number");
scanf("%d", &b);
*result = (a / b);
}