Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C
#include <stdio.h>
#include <math.h>
#define G 32

int main(){
    int i=0, t=1, distance, D=(1/2)*G* pow(1,2), height=distance-D;

    printf("What is the height of the dragon's nest in feet?\n ");
    scanf("%d", &distance);
    printf("Time\tAltitude\n");

        if (distance<= 0)
            printf("0\t0\n");

        while (distance>0) {
            D=distance-D;
            printf("%d\t%d.\n",t, D);
            }

return 0;
}
Posted
Updated 20-Sep-15 17:40pm
v8
Comments
PIEBALDconsult 20-Sep-15 23:40pm    
Obviously you don't, so why are you asking us?

1 solution

If you want to understand what is wrong in this program, I suggest to run it in debugger mode.
Run it step by step and check variables against expected values, you should see pretty fast what is wrong.

First hint "^" is not what you think it is. Read documentation for solution.

I guess the tittle is what is supposed to do the program. So there is not even a question.
 
Share this answer
 
Comments
Member 11998575 20-Sep-15 23:19pm    
I am suppose to make a table of the time and altitude per second of a baby dragon falling from a nest and the only user input allowed is the height of the dragons nest.

Thanks for the help I needed to use the pow function and the math.h library to square the variable, however I am still getting undesirable results could you offer any more hints?
Patrice T 20-Sep-15 23:30pm    
Use the debugger and check variables
Member 11998575 20-Sep-15 23:32pm    
Sorry EXTREMELY new to coding with C, I am currently using CodeBlocks I see the debugger tab could you walk me through how to check the variables?
Patrice T 20-Sep-15 23:36pm    
A debugger is a runtime tool that allow you to run your program step by step and see the variables.
You have to dig in your documentation or find a tuto.
I am not user of CodeBlocs

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900