review 2 version B ai7Eeu

review 2 version B ai7Eeu - { printf("\nPlease...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 Review 2 Test Version B 1.) #include <stdio.h> #include <stdlib.h> int main(void) { int x,steps1=0,steps2=0 printf("Please input an integer ") while(x>1) { if(x%2 == 0) { x=x/2 printf("%d\n",x) steps1++ } else { x=3*x+1 printf("%d\n",x) steps2++ } } printf("Number of steps is %d", steps1+steps2) getchar() getchar() return (0) } 2.) #include <stdio.h> #include <stdlib.h> #include <math.h> int main(void) {
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sheet1 Page 2 int a,b,c,d,option,e option = 0 printf("Please enter a value for (a,b): ") printf("\nPlease enter a value for (c,d): ")
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { printf(&quot;\nPlease choose between function 1 (Addition), 2 (Subtraction), or 3 (Modulus) &quot;) scanf(&quot;%d&quot;,&amp;option) } if(option == 1) { printf(&quot;\nAddition of a,c = %d&quot;, (a+c)) printf(&quot;\nAddition of b,d = %d&quot;, (b+d)) } if(option == 2) { printf(&quot;\nSubtraction of a,c = %d&quot;, (a-c)) printf(&quot;\nSubtraction of b,d = %d&quot;, (b-d)) } if(option == 3) { printf(&quot;\nModulus of a,b = %f&quot;, pow((pow(a,2)+pow(b,2)),0.5)) printf(&quot;\nModulus of c,d = %f&quot;, pow((pow(c,2)+pow(d,2)),0.5)) } getchar() getchar() return 0 }...
View Full Document

This note was uploaded on 02/13/2009 for the course ME 205 taught by Professor Koen during the Spring '07 term at University of Texas at Austin.

Page1 / 2

review 2 version B ai7Eeu - { printf(&amp;amp;quot;\nPlease...

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