Question: Introduction to C Programming COP 3223 Objectives 1. To reinforce the use of If-Else statements 2. To learn how to use while loops Introduction: Who
Introduction to C Programming COP 3223
Objectives
1. To reinforce the use of If-Else statements
2. To learn how to use while loops
Introduction: Who doesnt love dragons?
Movies about dragons and dragon training were very popular this summer. Your friend has not stopped talking about how awesome dragons are and how cool it would be to train them. To amuse your friend, you have decided to create a series of programs about dragons.
Problem: Learning to Fly (dragonfalling.c)
Dragons, like most birds, learn to fly from a combination of instinct and practice. If a bird falls out of a nest, instinct allows them to spread their wings and glide to the ground. Eventually, falling becomes more controlled and trips back to the nest become actual flights.
However, dragons have the advantage of intelligence on their side. They can determine how many seconds they have to open their wings for gliding instead of crashing.
In this program, the user will enter an altitude for the dragon nest. Use the following formula to determine how many feet the dragon will fall per second. Then, print out the elevation of the dragon for each second it is in the air. The last line of output should be the first second that the dragon is back on the ground.
D = * g * t2
Assume earths gravity is 32 ft/sec2.
Input Specification
1. The only integer entered (the height of the dragons nest) will be positive.
Output Specification
Create a chart with the first line as follows:
Time Altitude
Each following line will have two pieces of information, separated by tabs: the number of seconds after the dragon has left the nest, and the altitude of the dragon at that time. Both values should be printed out as integers. Note: The dragon cant have a negative height. Once it lands on the ground, it stays there, at height 0.
Output Samples
Below are some sample outputs of running the program. Note that these samples are NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above. In the sample run below, for clarity and ease of reading, the user input is given in italics while the program output is in bold. (Note: When you actually run your program no bold or italics should appear at all. These are simply used in this description for claritys sake.)
Sample Run 1
What is the height of the dragons nest?
120
Time Altitude
1 104
2 56
3 0
Sample Run 2
What is the height of the dragons nest?
300
Time Altitude
1 284
2 236
3 156
4 44
5 0
Deliverables
One source files dragonfalling.c is to be submitted over WebCourses.
Restrictions
Although you may use other compilers, your program must compile and run using Code::Blocks. Your program should include a header comment with the following information: your name, course number, section number, assignment title, and date. Also, make sure you include comments throughout your code describing the major steps in solving the problem.
Grading Details
Your programs will be graded upon the following criteria:
1) Your correctness
2) Your programming style and use of white space. Even if you have a plan and your program works perfectly, if your programming style is poor or your use of white space is poor, you could get 10% or 15% deducted from your grade.
3) Compatibility You must submit C source files that can be compiled and executed in a standard C Development Environment. If your program does not compile, you will get a sizable deduction from your grade.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
