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

For C code: Do not use any function other than getchar, scanf, and printf Q2.A) Write...
For C code: Do not use any function other than getchar, scanf, and printf Q2.A) Write a program to do the following: Read in two values into variables X   and y from the keyboard (they may be decimal values like 2.3). Read in a 3rd value (which is really small < 1.0 ) into variable E. Using a loop find out the value of N in the below expression. i.e. Each iteration of the loop reduced the value of Y...
Can someone convert this code to use printf & scanf instead of cin and cout #include...
Can someone convert this code to use printf & scanf instead of cin and cout #include <iostream> int main() { int n, i = 0; float RF, PFD, Tn = 0, Ts; std::cout << "**** Welcome to the Time Study Program ****" << std::endl; std::cout << "\nEnter the number of elements for the given operation being performed" << std::endl; std::cout << "Number of Elements: "; std::cin >> n; if (n < 0) { std::cout << "\nNumber of elements cannot be...
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.
Write a Java program that uses printf, and takes user input to find the name of...
Write a Java program that uses printf, and takes user input to find the name of the File. FileCompare (20) Write a program that compares to files line by line, and counts the number of lines that are different. You can use file1.txt and file2.txt when testing your program, but you must ask for the file names in the input. main Interactively requests the names of the two files, after creating the Scanner for the keyboard. Creates a Scanner for...
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 code in C# - (C - Sharp) Assignment Description Write out a program that will...
Please code in C# - (C - Sharp) Assignment Description Write out a program that will ask the user for their name; the length and width of a rectangle; and the length of a square. The program will then output the input name; the area and perimeter of a rectangle with the dimensions they input; and the area and perimeter of a square with the length they input. Tasks The program needs to contain the following A comment header containing...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT