Advertisement
freeridre

szamologep

Sep 20th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.25 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     float a,b,c;
  7.     int i,e;
  8.     printf("Hello! Ez a program szamolni tud!\n");
  9.     printf("\n");
  10.  
  11.     /*Szamologep*/
  12.  
  13.  
  14.  
  15.             while (i<5 || i>0 || e==1)
  16.                 {
  17.  
  18.                 printf("\n");
  19.                 printf("Mit szeretnel csinalni:\n");
  20.                 printf("\n");
  21.                 printf("-Kivonni(1)\n-osszeadni(2)\n-szorozni(3)\n-osztani(4)\n");
  22.                 printf("\n");
  23.                 scanf("%d", &i);
  24.                 printf("\n");
  25.  
  26.                         if (i>0 || i<5)
  27.                             {
  28.                                 if (i==1)
  29.                                 {
  30.                                 printf("Add meg az elso szamot!\n");
  31.                                 scanf("%f", &a);
  32.                                 printf("Add meg a masodik szamot!\n");
  33.                                 scanf("%f", &b);
  34.                                 c=a-b;
  35.                                 printf("Az osszeg %f.\n", c);
  36.                                 printf("\n");
  37.                                 }
  38.                                 if (i==2)
  39.                                 {
  40.                                 printf("Add meg az elso szamot!\n");
  41.                                 scanf("%f", &a);
  42.                                 printf("Add meg a masodik szamot!\n");
  43.                                 scanf("%f", &b);
  44.                                 c=a+b;
  45.                                 printf("Az osszeg %f.\n", c);
  46.                                 printf("\n");
  47.                                 }
  48.                                 if (i==3){
  49.                                 printf("Add meg az elso szamot!\n");
  50.                                 scanf("%f", &a);
  51.                                 printf("Add meg a masodik szamot!\n");
  52.                                 scanf("%f", &b);
  53.                                 c=a*b;
  54.                                 printf("Az osszeg %.2f. \n", c);
  55.                                 printf("\n");
  56.                                 }
  57.                                 if (i==4)
  58.                                 {
  59.                                 printf("Add meg az elso szamot!\n");
  60.                                 scanf("%f", &a);
  61.                                 printf("Add meg a masodik szamot!\n");
  62.                                 scanf("%f", &b);
  63.                                 c=a/b;
  64.                                 printf("Az osszeg %.2f. \n", c);
  65.                                 printf("\n");
  66.                                 }
  67.                                 else if (i>4 || i<1)
  68.                                 {
  69.                                 printf("Rossz szamot adtal meg!\n");
  70.                                 printf("\n");
  71.                                 printf("\n");
  72.                                 }
  73.  
  74.  
  75.  
  76.                             }
  77.  
  78.  
  79.                 printf("Szeretnel meg szamolni? 1(igen)/2(nem)\n");
  80.                 printf("\n");
  81.                 scanf("%d", &e);
  82.                 if (e==2)
  83.                     {
  84.                     printf("Koszonom, hogy hasznaltad a programom.");
  85.                     printf("\n");
  86.                     exit(2);
  87.                 }
  88.  
  89.  
  90.  
  91.                 }
  92.  
  93.  
  94.  
  95.     return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement