Write a program to calculate AB You should type in A and B
Write a program to calculate | A-B |. You should type in A and B running the program. Write a program using a function to calculate squareroot A-B, If A>B, the result will be squareroot A - B, if A
Solution
1.Program 1
#include<stdio.h>
int main()
{
int A,B,C;
printf(\"enter the value of A\");
scanf(\"%d\",&A);
printf(\"enter the value of B\");
scanf(\"%d\",&B);
C=A-B;
D=abs(c);
printf(\"the answer is %d\",D);
return 0;
}
2.Program 2
#include<stdio.h>
int main()
{
int A,B,C;
double D;
printf(\"enter the value of A\");
scanf(\"%d\",&A);
printf(\"enter the value of B\");
scanf(\"%d\",&B);
if(A>B)
{
C=A-B;
D=sqrt(C);
printf(\"the answer is %.2lf\",D);
}
else if(A<B)
{
C=B-A;
D=sqrt(C);
printf(\"the answer is %.2lf\",D);
}
else
{
prinf(\"A and B are equal\");
}
return 0;
}

