Question

Whats wrong with my code? Please help! #include <stdio.h> int main() { //variables int m1, m2,...

Whats wrong with my code? Please help!

#include <stdio.h>

int main()

{

//variables

int m1, m2, m3;

int a1, a2, a3;

int f1, f2, f3;

//input acceleration

printf("Enter value for a1: ");

printf("Enter value for a2: ");

printf("Enter value for a3: ");

scanf("%d %d %d",&a1,&a2,&a3);

//input mass

printf("Enter value for m1: ");

printf("Enter value for m2: ");

printf("Enter value for m3: ");

scanf("%d %d %d",&m1,&m2,&m3);

//functions

f1=m1*a1;

m1=f1/a1;

a1=f1/m1;

f2=m2*a2;

m2=f2/a2;

a2=f2/m2;

f3=m3*a3;

m3=f3/a3;

a3=f3/m3;

//command:

printf("f1=%d\n, m1=%d\n, a1=%d\n");

printf("f2=%d\n, m2=%d\n, a2=%d\n");

printf("f3=%d\n, m3=%d\n, a3=%d\n");

return 0;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>
int main()
{
    //variables
    int m1, m2, m3;
    int a1, a2, a3;
    int f1, f2, f3;
    //input acceleration
    printf("Enter value for a1: ");
    printf("Enter value for a2: ");
    printf("Enter value for a3: ");
    scanf("%d", &a1);
    scanf("%d", &a2);
    scanf("%d", &a3);
    //input mass
    printf("Enter value for m1: ");
    printf("Enter value for m2: ");
    printf("Enter value for m3: ");
    scanf("%d", &m1);
    scanf("%d", &m2);
    scanf("%d", &m3);
    //functions
    f1 = m1 * a1;
    m1 = f1 / a1;
    a1 = f1 / m1;
    f2 = m2 * a2;
    m2 = f2 / a2;
    a2 = f2 / m2;
    f3 = m3 * a3;
    m3 = f3 / a3;
    a3 = f3 / m3;
    //command:
    printf("f1=%d, m1=%d, a1=%d\n", f1, m1, a1);
    printf("f2=%d, m2=%d, a2=%d\n", f2, m2, a2);
    printf("f3=%d, m3=%d, a3=%d\n", f3, m3, a3);
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Whats wrong with my code? Please help! #include <stdio.h> int main() { //variables int m1, m2,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm having trouble rounding the numbers i'm getting in my output here's my code: #include<stdio.h> int...

    I'm having trouble rounding the numbers i'm getting in my output here's my code: #include<stdio.h> int main() { char gender; float a1, a2, a3, a4, a5; float waistmeasurement, wristmeasurement, hipmeasurement, forarmmeasurement; float B, bodyweight, Bodyfat, Bodyfatpercentage;    printf("This program determines the body fat of a person.Enter your gender (f|F|m|M): "); scanf("%c", &gender); printf("\n");    if(gender=='F' || gender=='f'){ printf("Enter body weight (in pounds): \n"); scanf("%f", &bodyweight); printf("Enter wrist measurement at fullest point (in inches): \n"); scanf("%f", &wristmeasurement); printf("Enter waist measurement at...

  • Solve using C programming 3. lf you are given this code. #include <stdio.h> int main() int...

    Solve using C programming 3. lf you are given this code. #include <stdio.h> int main() int var1, var2; int sum; printf("Enter number 1:\n "); scanf("%d",&var1); printf("Enter number 2:In ); scanf("%d",&var2); sum-var1+var2; printf ("Vnsum of two entered numbers : %d", //printf ("Output: %d", res); sum); return e; Modify this code by creating a function called "addition". Make the arguments of the functions numberl and number 2. Add the two values in the function. Return a value called "result". Print "result" in...

  • i need flowchart for the following c code #include <stdio.h> int main() {     int n,...

    i need flowchart for the following c code #include <stdio.h> int main() {     int n, i, sum = 0;     printf("Enter an integer: ");     scanf("%d",&n);     i = 1;     while ( i <=n )     {         sum += i;         ++i;     }     printf("Sum = %d",sum);     return 0; }

  • All in C please~ #1 Consider this program: #include <stdio.h> int main () { /* main...

    All in C please~ #1 Consider this program: #include <stdio.h> int main () { /* main */ constint constant1 = 10, constant2 = 20, constant3 = 14; int input_value; char current_truth; printf("What is the input value?\n"); scanf("%d", &input_value); current_truth = input_value > constant1; printf("current_truth = %d\n", current_truth); current_truth = current_truth && (input_value < constant2); printf("current_truth = %d\n", current_truth); current_truth = current_truth && (input_value == constant3); printf("current_truth = %d\n", current_truth); } /* main */ What is the output of this program...

  • Convert the below C code to basic MIPS. Please leave comments for explanation #include <stdio.h> int main(void) {...

    Convert the below C code to basic MIPS. Please leave comments for explanation #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b; scanf("%d",&a); scanf("%d",&b); a=a<<2; b=b<<2; printf("%d&%d\n",a,b); return 0; }

  • Convert the below C code to basic MIPS. Leave comments for explanation please #include <stdio.h> int main(void) {...

    Convert the below C code to basic MIPS. Leave comments for explanation please #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b,c; scanf("%d",&a); scanf("%d",&b); c=a|b; printf("%d|%d=%d\n",a,b,c); return 0; }

  • Do you have a flowgorithim flow chart for this code? #include <stdio.h> int main() { int num,i=0,sum=0; float aver...

    Do you have a flowgorithim flow chart for this code? #include <stdio.h> int main() { int num,i=0,sum=0; float average; int customerNumbers[num]; int customerSales[num]; printf("How many customers do you want to track?\n"); scanf("%d",&num); while(i<num) { printf("Enter the customer number. "); scanf("%d",&customerNumbers[i]); printf("Enter the sales for the customer "); scanf("%d",&customerSales[i]); i++; } printf("Sales for the Customer"); printf("\nCustomer Customer"); printf("\nNumber Sales"); for(i=0;i<num;i++) { printf("\n %d \t %d",customerNumbers[i], customerSales[i]); sum=sum+customerSales[i]; } average=(int)sum/num; printf("\n Total sales are $%d",sum); printf("\n Average sales are $%.2f",average); printf("\n --------------------------------------------");...

  • C program-- the output is not right please help me to correct it. #include <stdio.h> int...

    C program-- the output is not right please help me to correct it. #include <stdio.h> int main() { int arr[100]; int i,j,n,p,value,temp; printf("Enter the number of elements in the array: \n "); scanf("%d",&n); printf("Enter %d elements in the array: \n",n); for(i=0;i<n;i++) { printf("\nelement %d: ",i); scanf("\n%d",&arr[i]); } printf("\nEnter the value to be inserted: \n "); scanf("\n%d",&value); printf("The exist array is: \n"); for(i=0;i<n;i++) { printf("%d",arr[i]); } p=i; for(i=0;i<n;i++) if(value<arr[i] ) { p = i; break; } arr[p]=value; printf("\n"); for (i =...

  • Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int...

    Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int *); void replaceAt(int *, int, int); int isEmpty(int *, int); int isFull(int *, int); void removeAt(int *, int); void printList(int *, int); int main() { int *a; int arraySize=0,l=0,loc=0; int choice; while(1) { printf("\n Main Menu"); printf("\n 1.Create list\n 2.Insert element at particular position\n 3.Delete list.\n4. Remove an element at given position \n 5.Replace an element at given position\n 6. Check the size of...

  • Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main() {     int...

    Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main() {     int number;     scanf("%d", &number);     if (number % 2 == 0) {         printf("Even\n");     }     else {         printf("Odd\n");     }     return 0; }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT