Answer to Question #163688 in C for Monissha

Question #163688

Write a program to convert kilogram to gram and pound.

● Declare an array as a global variable, called kilo with 4 elements.


● In main():

▪ Call function get_input().

▪ Call function convert_gram().

▪ Call function convert_pound().


● In get_input():

 Using for loop, prompt the user to input the values in kilogram and store them in the

array kilo.


● In convert_gram():

▪ Use for loop to convert the values in grams and display the values.

▪ Formula: 1 kg = 1000 g


● In convert_pound():

▪ Use for loop to convert the values in pounds and display the values.

▪ Formula: 1 kg = 2.205 pounds


1
Expert's answer
2021-02-14T23:59:51-0500
#include<stdio.h>
#include<conio.h>
float n[4];

void get_input(float n[]){

printf("enter the values, (in kilogram) \n");

for(int i=1;i<=4;i++){
    scanf("%f",&n[i]);
}
 for(int i=1;i<=4;i++){
    printf("%0.2f",n[i]);
    printf("  ");
}
}
void convert_gram(float n[]){
    printf("\n\nThe conversion of kg to gram is given below \n \n");
for(int i=1;i<=4;i++){
    printf("%0.2f ",n[i]*1000);
    printf("gram  ");
}
}
void convert_pound(float n[]){
printf("\n \n The conversion of kg to pound is given below \n \n");
for(int i=1;i<=4;i++){
    printf("%0.2f",n[i]*2.205);
    printf("pound  ");
}
printf("\n");
}

int main(){

get_input(n);
convert_gram(n);
convert_pound(n);
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS