Skip to content

Instantly share code, notes, and snippets.

@savaryna
Created December 4, 2014 14:17
Show Gist options
  • Save savaryna/38fc05990a9b5c82dd2f to your computer and use it in GitHub Desktop.
Save savaryna/38fc05990a9b5c82dd2f to your computer and use it in GitHub Desktop.
#include <conio.h>
#include <stdio.h>
#include <math.h>
float cateta(float x, float y){
float cat;
printf("Dati marimea ipotenuzei in (cm): ");
scanf("%f", &x);
printf("Dati marimea catetei in (cm): ");
scanf("%f", &y);
cat=sqrt(pow(x,2)-pow(y,2));
return cat;
}
void laturi(){
printf("\n���������� LATURILE ��������ͻ\n");
printf("� Cateta opusa ----------- 1 �\n");
printf("� Cateta alaturata ------- 2 �\n");
printf("� Ipotenuza -------------- 3 �\n");
printf("� Iesi ------------------- 0 �\n");
printf("����������������������������ͼ");
}
void main(){
float a,b,c;
int l;
system("cls");
laturi();
do {
printf("\n\nCe latura doriti sa aflati: ");
scanf("%d", &l);
switch(l){
case 1: b=cateta(c,a);
printf("Marimea catetei opuse este: %.2f (cm)", b); break;
case 2: a=cateta(c,b);
printf("Marimea catetei alaturate este: %.2f (cm)", a); break;
case 3:
printf("Dati marimea catetei alaturate in (cm): ");
scanf("%f", &a);
printf("Dati marimea catetei opuse in (cm): ");
scanf("%f", &b);
c=sqrt(pow(a,2)+pow(b,2));
printf("Marimea ipotenuzei este: %.2f (cm)", c); break;
}
}
while(l!=0);
getch ();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment