unit 02 version C eix3th

unit 02 version C eix3th - return (0) } 3)Hexidecimal to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 1) Sum Of N #include <stdio.h> #include <math.h> int main(void) { int n int sum int sum2 = 0 printf("Please input the vaule of n:") while(n>0) { sum= (n*(n+1))/2 sum2=sum + sum2 n-- } printf("%d", sum2) return (0) } 2) ERRORS #include <stdio.h> #include <math.h> int main(void) { float a, b, c, cost printf("Please input the lengths of the three sides of the triangle\n") cost= (a*a+b*b-c*c)/(2.0*a*b) printf("The cosine of the included angle between a and b is: %f", cost)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return (0) } 3)Hexidecimal to decimal 2 * 16^0 = 2*1 = 2 8 * 16^1 = 8*16 = 128 5 * 16^2 = 5*256= 1280 ANSWER = 1410 #include <stdio.h> #include <math.h> int main(void) Sheet1 Page 2 { float a, b, c, d, e, f printf("Please input Mass 1, Velocity 1, Mass 2, Velocity 2\n") scanf("%f %f %f %f", &a,&b,&c,&d) e = (a*b) f = (c*d) if (e>d) { printf("\n%f", e) } else if (d>e) { printf("\n%f",f) } else { printf("\n%f",f) } scanf("%d",&d) return (0) }...
View Full Document

This note was uploaded on 09/11/2008 for the course ME 205 taught by Professor Koen during the Spring '07 term at University of Texas.

Page1 / 2

unit 02 version C eix3th - return (0) } 3)Hexidecimal to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online