Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the assignment #include<stdio.h> void convert_length(); void convert_wei

ID: 3758324 • Letter: T

Question

This is the assignment

#include<stdio.h>
void convert_length();
void convert_weight();

void length_to_metric(int*);
void length_to_us(int*);

void weight_to_metric(int*);
void weight_to_us(int*);
int main() {
   int n;
   do {
       printf("Press 1 for length and 2 for weight : ");
       scanf("%d", &n);
       while (n > 2) {
           printf("Invalid entry : Press 1 for length and 2 for weight : ");
           scanf("%d", &n);
       }
       if (n == 1)
           convert_length();
       if (n == 2)
           convert_weight();
   } while (n != 0);
   return 0;
}
void convert_length() {
   int length = 0;
   int n = 0;

   do {
       printf("Press 1:From feet/inches to meters/centimeters "
           "Press 2:From meters/centimeters to feet/inches "
           "Presse 0:Exit ");
       scanf("%d", &n);
       while (length > 2) {
           printf("Invalid entry : ");

           printf("Press 1:From feet/inches to meters/centimeters "
               "Press 2:From meters/centimeters to feet/inches "
               "Presse 0:Exit ");
           scanf("%d", &n);
       }

       if (n == 1) {
           length_to_metric(&length);
       }
       if (n == 2) {
           length_to_us(&length);
       }
       if (n == 0) {
           return;
       }
   } while (n != 0);

}

void length_to_metric(int *length) {
   printf("From feet/inches to meters/centimeters is called ");
}

void length_to_us(int *length) {
   printf("From meters/centimeters to feet/inches is called ");

}
void convert_weight() {
   int weight = 0;
   int n = 0;

   do {
       printf("Press 1:from pounds/ounces to kilograms/grams "
           "Press 2:from kilograms/grams to pounds/ounces "
           "Presse 0:Exit ");
       scanf("%d", &n);
       while (n > 2) {
           printf("Invalid entry : ");
           printf("Press 1:from pounds/ounces to kilograms/grams "
               "Press 2:from kilograms/grams to pounds/ounces "
               "Presse 0:Exit ");
           scanf("%d", &n);
       }
       if (n == 1) {
           weight_to_metric(&weight);
       }
       if (n == 2) {
           weight_to_us(&weight);
       }
       if (n == 0) {
           return;
       }

   } while (n != 0);

}

void weight_to_metric(int *weight) {
   printf("from pounds/ounces to kilograms/grams is called ");

}
void weight_to_us(int *weight) {
   printf("from kilograms/grams to pounds/ounces ");

}

This is my Daily18

Help this assignment.

Explanation / Answer

I think length variable is not required in convert_length and weight variable is not required in convert_weight functions. why because you are not reading these varibles simply your passing variables to correspoind functions. I corrcted above code and running is fine..

#include<stdio.h>
void convert_length();
void convert_weight();

void length_to_metric(int*);
void length_to_us(int*);

void weight_to_metric(int*);
void weight_to_us(int*);
int main() {
    int n;
    do {
        printf("Press 1 for length and 2 for weight : ");
        scanf("%d", &n);
        while (n > 2) {
            printf("Invalid entry : Press 1 for length and 2 for weight : ");
            scanf("%d", &n);
        }
        if (n == 1)
            convert_length();
        if (n == 2)
            convert_weight();
    } while (n != 0);
    return 0;
}
void convert_length() {
    int length = 0;
    int n = 0;

    do {
        printf("Press 1:From feet/inches to meters/centimeters "
               "Press 2:From meters/centimeters to feet/inches "
               "Press 0:Exit ");
        scanf("%d", &n);
        while (n > 2) {
            printf("Invalid entry : ");
            printf("Press 1:From feet/inches to meters/centimeters "
                    "Press 2:From meters/centimeters to feet/inches "
                    "Presse 0:Exit ");
            scanf("%d", &n);
        }

        if (n == 1) {
            length_to_metric(&length);
        }
        if (n == 2) {
            length_to_us(&length);
        }
        if (n == 0) {
            return;
        }
    } while (n != 0);
}

void length_to_metric(int *length) {
    printf("From feet/inches to meters/centimeters is called ");
}

void length_to_us(int *length) {
    printf("From meters/centimeters to feet/inches is called ");

}
void convert_weight() {
    int weight = 0;
    int n = 0;

    do {
        printf("Press 1:from pounds/ounces to kilograms/grams "
            "Press 2:from kilograms/grams to pounds/ounces "
            "Presse 0:Exit ");
        scanf("%d", &n);
        while (n > 2) {
            printf("Invalid entry : ");
            printf("Press 1:from pounds/ounces to kilograms/grams "
                "Press 2:from kilograms/grams to pounds/ounces "
                "Presse 0:Exit ");
            scanf("%d", &n);
        }
        if (n == 1) {
            weight_to_metric(&weight);
        }
        if (n == 2) {
            weight_to_us(&weight);
        }
        if (n == 0) {
            return;
        }

    } while (n != 0);

}

void weight_to_metric(int *weight) {
    printf("from pounds/ounces to kilograms/grams is called ");

}
void weight_to_us(int *weight) {
    printf("from kilograms/grams to pounds/ounces ");

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote