Advertisement
Guest User

Volumenrechner

a guest
Nov 25th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int volumen (int x, int y, int z) {
  5.     return x*y*z;
  6. }
  7.  
  8. int oberflaeche(int x, int y, int z) {
  9.     return (2*x*y)+(2*x*z)+(2*y*z);
  10. }
  11.  
  12. int main(int argc, char *argv[]) {
  13.     int a, b, c, s;
  14.     printf("a = ");
  15.     scanf("%d", &a);
  16.     printf("b = ");
  17.     scanf("%d", &b);
  18.     printf("c = ");
  19.     scanf("%d", &c);
  20.     printf("(1) Volumen \n");
  21.     printf("(2) Oberflaeche \n");
  22.     printf("Auswahl (1-2): ");
  23.     scanf("%d", &s);
  24.    
  25.     if (s == 1) {
  26.         printf("Volumen: %d m^3", volumen(a,b,c));
  27.     }
  28.     else if (s == 2) {
  29.         printf("Oberflaeche: %d qm", oberflaeche(a,b,c));
  30.     }
  31.     else {
  32.         printf("Fehlerhafte Eingabe!");
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement