Scientific Calculator Assignment 3
Scientific Calculator Assignment 3
Dr. A. Q. Khan Institute of Computer Sciences & Information Technology KRL, Kahuta
1 Computer Programming
break; case 3: printf("Enter Number to Find its inverse:"); scanf("%f",&num_f); re_f=inverse(num_f); printf("Inverse of %.f is %.3f",num_f,re_f); break; case 4: printf("Enter Number to find its factorial:"); scanf("%d",&num); re=fact(num); printf("Factorial of %d is %d",num,re); break; case 5: printf("Enter Number to Find its Natural Log:"); scanf("%f",&num_f); re_d=log(num_f); printf("Natural Log of %.2f is %.2f",num_f,re_d); break; case 6: printf("Enter Number to Find its Log:"); scanf("%f",&num_f); re_d=log10(num_f); printf("Log of %.2f is %.2f",num_f,re_d); break; case 7: printf("Enter Number to Find its Sin Value:"); scanf("%f",&num_f); re_d=si(num_f); printf("Sin of %.f is %.3f",num_f,re_d); break; case 8: printf("Enter Number to Find its Cos Value:"); scanf("%f",&num_f); re_d=co(num_f); printf("cos of %.f is %.3f",num_f,re_d); break; case 9: printf("Enter Number to Find its Tan Value:"); scanf("%f",&num_f); re_d=ta(num_f); printf("Tangent of %.f is %.3f",num_f,re_d); break; case 10: printf("Enter Number to Find its Cotagant Value:"); scanf("%f",&num_f); re_d=ta(num_f); re_d1=1/re_d; 3 Computer Programming
printf("Cotangent of %f is %f",num_f,re_d1); break; case 11: printf("Enter Number to Find its Cosec Value:"); scanf("%f",&num_f); re_d=si(num_f); re_d1=1/re_d; printf("Cosec of %f is %f",num_f,re_d1); break; case 12: printf("Enter Number to Find its Sec Value:"); scanf("%f",&num_f); re_d=co(num_f); re_d1=1/re_d; printf("Sec of %f is %f",num_f,re_d1); break; default: printf("Invalid Number"); } getch(); } int power(int x, int y) { int z; z=pow(x,y); return z; } float inverse(float x) { float z; z=1/x; return z; } double si(float x) { double z; z=sin(x); return z; } double co(float x) { double z; z=cos(x); return z; } double ta(float x) { double z; 4 Computer Programming
5 Computer Programming