1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include<dos.h>
double val=180;
char choice;
sinLaw();
case1()
{
double a1,a2,s1,b,c,C;
clrscr();
printf("Enter value for Angle A:\n");
scanf("%d",&a1);
printf("Enter value for Angle B:\n");
scanf("%d", &a2);
printf("Enter value for Side a:\n");
scanf("%d", &s1);
b=((s1*sin(a1))/sin(a2));
c=((s1*(180-(a1+a2)))/sin(s1))/val;
C=asin((c*(sin(a2))/s1)*3.1416/val);
printf("\n\n\t b=%d\n\n\t", b);
printf("c=%d\n\n\t", c);
printf("C=%d\n\n\n\t\t\t", C);
printf("Would you like to try again?[Y/N]:");
scanf("%c", &choice);
if((choice=='Y')||(choice=='y'))
{
sinLaw();}
else if((choice=='N')||(choice=='y'))
{
exit(0);}
else{
printf("\t\t\tInvalid input!...");}
clrscr();
printf("\n\n\n\t\t\tWould you like to try again?[Y/N]:");
scanf("%c",&choice);
if((choice=='Y')||(choice=='y'))
{
sinLaw();}
else if((choice=='N')||(choice=='n'))
{
exit(0);}
return 0;
}
case2()
{
double s1,s2,a1,c,C,B;
clrscr();
printf("Enter value for side a:\n");
scanf("%d", &s1);
printf("Enter value for side b:\n");
scanf("%d", &s2);
printf("Enter value for Angle A:\n");
scanf("%d", &a1);
B=asin((s2*sin(a1))/s1)/180;
C=180-(a1+B);
c=(s1*sin(C))/sin(a1);
printf("\n\n\tB:%d", B);
printf("\n\n\tC:%d", C);
printf("\n\n\tc:%d", c);
printf("\n\n\t\t\tWould you like to try again?[Y/N]");
scanf("%c", &choice);
if((choice=='y')||(choice=='y'))
{
sinLaw();}
else if((choice=='N')||(choice=='n'))
{
exit(0);}
else{
printf("\t\t\tInvalid input!...");
}
clrscr();
printf("\n\n\n\t\t\tWould you like to try again?[/N]:");
scanf("%c",&choice);
if((choice=='Y')||(choice=='y'))
{
sinLaw();}
else if((choice=='N')||(choice=='n'))
{
exit(0);}
return 0;
}
sinLaw()
{
char choice;
clrscr();
gotoxy(25,5);
printf("-----THE SINE LAW-----");
printf("\n\t\t\tCase 1: 2 Angles and 1 Side[1]:");
printf("\n\t\t\tCase 2: 2 Sides and 1 Angle [2]:");
printf("\n\n\t\t\tQuit[Q/q]:");
printf("\n\n\t\t\t\tEnter your choice:[]\b\b\b");
scanf("%c", &choice);
switch(choice)
{
case '1':case1();break;
case '2':case2();break;
case 'Q':exit(0);break;
case 'q':exit(0);break;
}
return 0;
}
main()
{
clrscr();
sinLaw();
getch();
}
|