Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2021
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | None | 0 0
  1. /*
  2. Name: William Horowitz
  3. Course: CSCI 1110-03
  4. Subject: Assignment 1
  5. Instructor: Dr. Reza Sadeghi
  6. Date: 02/23/2021
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <math.h>
  11.  
  12. int main (void) {
  13.     puts("\n\n\t************************\n\tWelcome to Billy's Calculator\n\t************************");
  14.    
  15.     double x,y;
  16.     char Operator;
  17.    
  18.     printf("Please enter the operation you want to perform +,-,*,/,s,e :");
  19.     scanf("%c",&Operator);
  20.    
  21.     printf("Please enter the first number :");
  22.     scanf("%lf",&x);
  23.    
  24.     printf("Please enter the second number :");
  25.     scanf("&lf",&y);
  26.    
  27.     if (Operator == "+")
  28.     {
  29.         puts("ADDITION");
  30.         printf("%.2f added to %.2f is %.2f\n",x,y,x+y);
  31.        
  32.        
  33.     }
  34.     else if (Operator == "-") {
  35.         printf("%.2f minus %.2f is %.2f\n",x,y,x-y);
  36.        
  37.     }
  38.     else if (Operator == "*") {
  39.         printf("%.2f multiplied by %.2f is %.2f\n",x,y,x*y);
  40.  
  41.     }  
  42.     else if (Operator == "/") {
  43.         printf("%.2f divided by %.2f is %.2f\n",x,y,x/y);
  44.        
  45.     }  
  46.     else if (Operator == "e") {
  47.         printf("%.2f to the power of 2 is %.2f and %.2f to the power of 2 is %.2f\n",x,x*x,y,y*y);
  48.    
  49.     }  
  50.  
  51.     return 0;
  52.    
  53. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement