1 / 8

Programming Project #1 Numerical Computations

Programming Project #1 Numerical Computations. CS-2301, System Programming for Non-Majors (Slides include materials from The C Programming Language , 2 nd edition, by Kernighan and Ritchie and from C: How to Program , 5 th and 6 th editions, by Deitel and Deitel). Purpose.

valariek
Download Presentation

Programming Project #1 Numerical Computations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Project #1Numerical Computations CS-2301, System Programmingfor Non-Majors (Slides include materials from The C Programming Language, 2nd edition, by Kernighan and Ritchie and from C: How to Program, 5th and 6th editions, by Deitel and Deitel) Circumference and Area of a Triangle

  2. Purpose • Write a simple C program that • Reads some data from the keyboard • Computes a simple engineering or scientific formula • Prints the answer on the output screen • The formula is supplied:– • Circumference and area of a triangle, given its three vertices Circumference and Area of a Triangle

  3. Your Program • Develop on CCC Linux system • Called triangle.c • Prompt user for inputs:– • Use scanf() • See §§B1.2-B1.3 of K & R • Repeat three times total • x- and y-coordinates each of points A, B, and C • Calculate and print • Lengths of the three sides of the triangle • Circumference of the triangle • Area of the triangle • Use printf() Circumference and Area of a Triangle

  4. Formulas • See handout • Length of side between A and B • Where point A is given by xA, yA • Where point B is given by xB, yB • Area is given by • Where s = ½  (lAB + lBC + lCA). Circumference and Area of a Triangle

  5. Sample Input Enter the x-coordinate of point A:- 1.05 Enter the y-coordinate of point A:- 2 Enter the x-coordinate of point B:- 1.115e+2 Enter the y-coordinate of point B:- 21.1 Enter the x-coordinate of point C:- -25 Enter the y-coordinate of point C:- -3.14159265358979323846 Circumference and Area of a Triangle

  6. Sample Output Length of AB is 112.089 Length of BC is 138.636 Length of CA is 26.553 Circumference is 277.278 Area is 35.181 Circumference and Area of a Triangle

  7. Things You Need to Know • sqrt(expression); • printf("string", arg1, arg2, …); • scanf("string", &arg1, &arg2, …); Circumference and Area of a Triangle

  8. Questions? Circumference and Area of a Triangle

More Related