C
Programming and Technical
Category
C language code for scientific calculator
Read Solution (Total 1)
-
- #include
#include
#include
int main(void) {
int choice, i, a, b;
float x, y, result;
clrscr();
do {
printf(“nSelect your operation (0 to exit):n”);
printf(“1. Additionn2. Subtractionn3. Multiplicationn4. Divisionn”);
printf(“5. Square rootn6. X ^ Yn7. X ^ 2n8. X ^ 3n”);
printf(“9. 1 / Xn10. X ^ (1 / Y)n11. X ^ (1 / 3)n”);
printf(“12. 10 ^ Xn13. X!n14. %n15. log10(x)n16. Modulusn”);
printf(“17. Sin(X)n18. Cos(X)n19. Tan(X)n20. Cosec(X)n”);
printf(“21. Cot(X)n22. Sec(X)n”);
printf(“Choice: “);
scanf(“%d”, &choice);
if(choice == 0) exit(0);
switch(choice) {
case 1:
printf(“Enter X: “);
scanf(“%f”, &x);
printf(“nEnter Y: “);
scanf(“%f”, &y);
result = x + y;
printf(“nResult: %f”, result);
break;
case 2:
printf(“Enter X: “);
scanf(“%f”, &x);
printf(“nEnter Y: “);
scanf(“%f”, &y);
result = x – y;
printf(“nResult: %f”, result);
break;
case 3:
printf(“Enter X: “);
scanf(“%f”, &x);
printf(“nEnter Y: “);
scanf(“%f”, &y);
result = x * y;
printf(“nResult: %f”, result);
break;
case 4:
printf(“Enter X: “);
scanf(“%f”, &x);
printf(“nEnter Y: “);
scanf(“%f”, &y);
result = x / y;
printf(“nResult: %f”, result);
break;
case 5:
printf(“Enter X: “);
scanf(“%f”, &x);
result = sqrt(x);
printf(“nResult: %f”, result);
break;
case 6:
printf(“Enter X: “);
scanf(“%f”, &x);
printf(“nEnter Y: “);
scanf(“%f”, &y);
result = pow(x, y);
printf(“nResult: %f”, result);
break;
case 7:
printf(“Enter X: “);
scanf(“%f”, &x);
result = pow(x, 2);
printf(“nResult: %f”, result);
break;
case 8:
printf(“Enter X: “);
scanf(“%f”, &x);
result = pow(x, 3);
printf(“nResult: %f”, result);
break;
case 9:
printf(“Enter X: “);
scanf(“%f”, &x);
result = pow(x, -1);
printf(“nResult: %f”, result);
break;
case 10:
printf(“Enter X: “);
scanf(“%f”, &x);
printf(“nEnter Y: “);
scanf(“%f”, &y);
result = pow(x, (1/y));
printf(“nResult: %f”, result);
break;
case 11:
printf(“Enter X: “);
scanf(“%f”, &x);
y = 3;
result = pow(x, (1/y));
printf(“nResult: %f”, result);
break;
case 12:
printf(“Enter X: “);
scanf(“%f”, &x);
result = pow(10, x);
printf(“nResult: %f”, result);
break;
case 13:
printf(“Enter X: “);
scanf(“%f”, &x);
result = 1;
for(i = 1; i - 9 years agoHelpfull: Yes(0) No(0)
C Other Question