printfEnter sum and difference of 2 real numbers scanflflfsumdif a sum dif2 b

# Printfenter sum and difference of 2 real numbers

This preview shows page 6 - 7 out of 7 pages.

printf("Enter sum and difference of 2 real numbers >"); scanf("%lf%lf",&sum,&dif); a = (sum + dif)/2; b = sum - a ; printf("number1 =%f\nnumber2 =%f",a,b); return 0; } 6
Question 9 ( 12 points) Write a program that reads 2 non zero integer numbers from the user then it will print one of the following messages: n1 is divisible by n2 n2 is divisible by n1 n1 and n2 are not divisible by each other Note: n1 and n2 represent the numbers typed by the user. You must print the values of the numbers typed by the user as shown below in the sample executions of your program. #include <stdio.h> int main() { int n1,n2; printf("Enter 2 non zero integer numbers >"); scanf("%d%d",&n1,&n2); if(n1%n2==0) printf("%d is divisible by %d",n1,n2); else if(n2%n1==0) printf("%d is divisible by %d",n2,n1); else printf("%d and %d are not divisible by each other",n1,n2); return 0; } 7

#### You've reached the end of your free preview.

Want to read all 7 pages?