{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

review 2 version B ai7Eeu

review 2 version B ai7Eeu - printf"\nPlease choose...

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 Document Right 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("\nPlease choose between function 1 (Addition), 2 (Subtraction), or 3 (Modulus) ") scanf("%d",&option) } if(option == 1) { printf("\nAddition of a,c = %d", (a+c)) printf("\nAddition of b,d = %d", (b+d)) } if(option == 2) { printf("\nSubtraction of a,c = %d", (a-c)) printf("\nSubtraction of b,d = %d", (b-d)) } if(option == 3) { printf("\nModulus of a,b = %f", pow((pow(a,2)+pow(b,2)),0.5)) printf("\nModulus of c,d = %f", pow((pow(c,2)+pow(d,2)),0.5)) } getchar() getchar() return 0 }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

review 2 version B ai7Eeu - printf"\nPlease choose...

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

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