Advertisement
makispaiktis

ΣΤΟΙΧΕΙΩΔΗΣ ΑΡΙΘΜΟΜΗΧΑΝΗ

Jan 5th, 2018 (edited)
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.  
  5.  printf("HERE IS A CALCULATOR.PRESS 1 FOR SUM, 2 FOR SUBTRACT, 3 FOR MULTIPLATION, 4 FOR DIVISION\n");
  6.  float x;
  7.  scanf("%f", &x);
  8.  
  9.  
  10.  if(x==1){
  11.  
  12.  printf("Give me 2 numbers to get its sum.\n");
  13.  float a,b;
  14.  scanf("%f",&a);
  15.  scanf("%f",&b);
  16.  printf("Sum is %f.\n", a+b);
  17.  }
  18.  
  19.  else if(x==2){
  20.  printf("Give me 2 numbers to get its variance.\n");
  21.  float c,d;
  22.  scanf("%f",&c);
  23.  scanf("%f",&d);
  24.  printf("The variance is %f.\n", c-d);
  25.  }
  26.  
  27. else if(x==3){
  28.  printf("Give me 2 numbers to get its product.\n");
  29.  float e,f;
  30.  scanf("%f",&e);
  31.  scanf("%f",&f);
  32.  printf("Sum is %f.\n", e*f);
  33.  }
  34.  
  35.  else if(x==4){
  36.  printf("Give me 2 numbers to get its .\n");
  37.  float g,h;
  38.  scanf("%f",&g);
  39.  scanf("%f",&h);
  40.  printf("The quotient is %f.\n", g/h);
  41.  }
  42.  
  43.  else{
  44. printf("Press 1 or 2 or 3 or 4!\n");  }
  45.  
  46.  
  47.  
  48.  return 0;
  49.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement