C Program S=(double)((double)((int)(S*100))/(double)(100));

How to write C Program to solve and finds out the answer S=(double)((double)((int)(S*100))/(double)(100)); in C Programming Language ?


Solution:


#include<math.h>
#include<stdio.h>

int main(){
      double a=0, b=0, c=0, d=3.141592653;
      scanf("%lf",&a);
      scanf("%lf",&b);
      scanf("%lf",&c);
      if(a>0 && b>0 && c>0){
            c=(c*d)/180;
            double S=a*b*sin(c)/2;
            double e=sqrt((a*a+b*b)-(2*a*b*cos(c)));
            double P=a+b+e;
//            S=(double)((double)((int)(S*100))/(double)(100));
            printf("S = %.3g / P = %.3g",S,P);
      }
      else printf("S = 0 / P = 0");
      return 0;
}


Learn More :