Created
January 24, 2018 00:07
-
-
Save hamzamuric/7b15a1d3f735d8102b046cd55de5b422 to your computer and use it in GitHub Desktop.
Program za racunanje obima i povrsine osnovnih geometrijskih oblika
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <conio.h> | |
#include <stdbool.h> | |
#define PI 3.141592653589793 | |
void clear(){ | |
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) | |
system("clear"); | |
#endif | |
#if defined(_WIN32) || defined(_WIN64) | |
system("cls"); | |
#endif | |
} | |
void kvadrat(); | |
void pravougliTrougao(); | |
void Krug(); | |
int main() | |
{ | |
unsigned short izbor = 0; | |
char opet; | |
bool jos = true; | |
while(jos){ | |
printf("Unesite s kojim goemetrijskim oblikom zelite da radite\n"); | |
printf("1 - Kvadrat\n2 - Pravougli trougao\n3 - Krug\n\n> "); | |
scanf("%d", &izbor); | |
switch (izbor){ | |
case 1: | |
kvadrat(); | |
break; | |
case 2: | |
pravougliTrougao(); | |
break; | |
case 3: | |
Krug(); | |
break; | |
default: | |
printf("Unesite odgovarajuci broj\n"); | |
continue; | |
} | |
printf("Zelite li ponovo da koristite program (D/N) : "); | |
scanf(" %c", &opet); | |
if(opet == 'D' || opet == 'd'){ | |
jos = true; | |
clear(); | |
} | |
} | |
return 0; | |
} | |
void kvadrat(){ | |
double a; | |
unsigned short izbor; | |
printf("Unesite stranicu kvadrata: "); | |
scanf("%lf", &a); | |
printf("\n\n"); | |
printf("Zelite li da izracunate obim ili povrsinu kvadrata?\n\n"); | |
printf("Za obim unesite 1, za povrsinu unesite 2\n\n> "); | |
scanf("%d", &izbor); | |
if (izbor == 1) | |
printf("Obim kvadrata je %lf\n\n", 4*a); | |
else if (izbor == 2) | |
printf("Povrsina kvadrata je %lf\n\n", a*a); | |
else | |
printf("Vas izbor je nevazeci\n\n"); | |
} | |
void pravougliTrougao(){ | |
double a, b; | |
unsigned short izbor; | |
printf("Unesite stranice trougla: "); | |
scanf("%lf %lf", &a, &b); | |
printf("\n\n"); | |
printf("Zelite li da izracunate obim ili povrsinu trougla?\n\n"); | |
printf("Za obim unesite 1, za povrsinu unesite 2\n\n> "); | |
scanf("%d", &izbor); | |
if (izbor == 1) | |
printf("Obim trougla je %lf\n\n", a+b); | |
else if (izbor == 2) | |
printf("Povrsina trougla je %lf\n\n", (a*b)/2); | |
else | |
printf("Vas izbor je nevazeci\n\n"); | |
} | |
void Krug(){ | |
double r; | |
unsigned short izbor; | |
printf("Unesite poluprecnik kruga: "); | |
scanf("%lf", &r); | |
printf("\n\n"); | |
printf("Zelite li da izracunate obim ili povrsinu kruga?\n\n"); | |
printf("Za obim unesite 1, za povrsinu unesite 2\n\n> "); | |
scanf("%d", &izbor); | |
if (izbor == 1) | |
printf("Obim kruga je %lf\n\n", 2*r*PI); | |
else if (izbor == 2) | |
printf("Povrsina kruga je %lf\n\n", r*r*PI); | |
else | |
printf("Vas izbor je nevazeci\n\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment