Question

In: Computer Science

please write it in printf and scanf please Please write it in c# program please and...

please write it in printf and scanf please Please write it in c# program please and if possible no arrays only loops Loop Introduction Assignment Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches. Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into BMI is as follows: BMI = Weight * 703 / Height2 Your function will do this using a for loop and must display the BMI for 3 people, one at a time. In other words, display the BMI for person 1 before asking for the next person’s information. Function #2: This function will do the exact same thing as function #1, except you will use a do-while loop. Function #3: Using a while loop, write the same steps as function #1, but as an indefinite loop where we continue to ask the user if they would like to calculate the BMI again. Continue to do so until the user replies with either an ‘N’ or an ‘n’ Reserve Point Opportunity!! Complete the above program calling a fourth function that will calculate and return the BMI.

Solutions

Expert Solution

Code

#include <stdio.h>

void BMI_using_for();

void BMI_using_dowhile();

void BMI_using_while();

double calculateBMI(double,double);

int main(void) {

BMI_using_for();

BMI_using_dowhile();

BMI_using_while();

return 0;

}

void BMI_using_for()

{

double weight;

double height,BMI;

int i;

printf("Funciton using for loop\n\n");

for(i=1;i<=3;i++)

{

printf("Enter weight in pounds: ");

scanf("%lf",&weight);

printf("Enter height in inches: ");

scanf("%lf",&height);

BMI=calculateBMI(weight, height);

printf("Persont %d's BMI: %.2lf\n\n",i,BMI);

}

}

void BMI_using_dowhile()

{

double weight;

double height,BMI;

int i=1;

printf("Funciton using do..while() loop\n\n");

do

{

printf("Enter weight in pounds: ");

scanf("%lf",&weight);

printf("Enter height in inches: ");

scanf("%lf",&height);

BMI=calculateBMI(weight, height);

printf("Persont %d's BMI: %.2lf\n\n",i,BMI);

i+=1;

}while(i<=3);

}

void BMI_using_while()

{

double weight;

double height,BMI;

char again='y';

int i=1;

printf("Funciton using while loop\n\n");

while(1)

{

printf("Enter weight in pounds: ");

scanf("%lf",&weight);

printf("Enter height in inches: ");

scanf("%lf",&height);

BMI=calculateBMI(weight, height);

printf("Persont %d's BMI: %.2lf\n\n",i,BMI);

i++;

fflush(stdin);

printf("Do you want to continue (y/n)? ");

again=getchar();

if(again=='n'||again=='N')

break;

}

}

double calculateBMI(double weight,double height)

{

return (weight * 703) / (height*height);

}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

Please Write C++ PROGRAM : That will write a program that initially prompts the user for...
Please Write C++ PROGRAM : That will write a program that initially prompts the user for a file name. If the file is not found, an error message is output, and the program terminates. Otherwise, the program prints each token in the file, and the number of times it appeared, in a well formatted manner. To accomplish all this, do the following: - Open the file - the user must be prompted and a file name input. DO NOT hardcode...
Write a program to calculate the area and circumference of a cuboid. Use printf to display...
Write a program to calculate the area and circumference of a cuboid. Use printf to display 2 digits after decimal point in all the results Program should be in java language.
Code in C# please. Write a program that will use the greedy algorithm. This program will...
Code in C# please. Write a program that will use the greedy algorithm. This program will ask a user to enter the cost of an item. This program will ask the user to enter the amount the user is paying. This program will return the change after subtracting the item cost by the amount paid. Using the greedy algorithm, the code should check for the type of bill. Example: Cost of item is $15.50 User pays a $20 bill $20...
Please write program in C++ format: Write a program to accept five negative numbers from the...
Please write program in C++ format: Write a program to accept five negative numbers from the user. (1) Find the average of the five numbers and display the answer to the standard output. Keep the answer two decimal points - 5 points (2) Output the numbers in ascending order and display the answer to the standard output. - 5 points
use linux or c program. please provide the answer in details. Write a program that will...
use linux or c program. please provide the answer in details. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally...
please write in c using linux or unix Write a program that will simulate non -...
please write in c using linux or unix Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
*Please write code in C++* Write a program to verify the validity of the user entered...
*Please write code in C++* Write a program to verify the validity of the user entered email address.   if email is valid : output the stating that given email is valid. ex: "The email [email protected] is valid" else : output the statement that the email is invalid and list all the violations ex:  "The email sarahwinchester.com is invalid" * @ symbol * Missing Domain name The program should keep validating emails until user enter 'q' Upload your source code. ex: main.cpp
Please write in C using linux or unix. Write a program that will simulate non -...
Please write in C using linux or unix. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
please write a C program that implements Quick Sort algorithm.
please write a C program that implements Quick Sort algorithm.
Please answer these The following array is declared: int grades[20]; a. Write a printf() statement that...
Please answer these The following array is declared: int grades[20]; a. Write a printf() statement that can be used to display values of the first, third, and seventh elements of the array. b. Write a scanf() statement that can be used to enter values into the first, third, and seventh elements of the array. c. Write a for loop that can be used to enter values for the complete array. d. Write a for loop that can be used to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT