Write a function to find the area of a triangle whose
length of three sides is given
Answer Posted / gajendra patil
#include <stdio.h>
#include <math.h>
float tarea(int a,int b,int c){
int cond1=0,cond2=0;
float s,area;
if((a > 0.0) && (b > 0.0) && (c > 0.0)){
cond1 = 1;
}
if((a+b > c) && (a+c > b) && (b+c > a)){
cond2 = 1;
}
if(cond1 && cond2){
s=(a+b+c)/2.0;
area= (sqrt(s*(s-a)*(s-b)*(s-c)));
printf("=================================\n");
printf("AREA OF TRIANGLE IS [ %f ]\n",area);
printf("=================================\n");
}else
printf("\nERROR: This is not a triangle!\n");
};
int main(){
int a,b,c;
float area;
printf("\nArea of Triangle");
printf("\n-------------------------\n");
printf("Enter three sides: \n");
printf("\nEnter size for a: ");
scanf("%d",&a);
printf("\nEnter size for b: ");
scanf("%d",&b);
printf("\nEnter size for c: ");
scanf("%d",&c);
tarea(a,b,c);
return 0;
}
| Is This Answer Correct ? | 15 Yes | 9 No |
Post New Answer View All Answers
Explain how can I remove the trailing spaces from a string?
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
Are there any problems with performing mathematical operations on different variable types?
In C programming, how do you insert quote characters (‘ and “) into the output screen?
Difference between Function to pointer and pointer to function
Differentiate between a for loop and a while loop? What are it uses?
The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.
When is a “switch” statement preferable over an “if” statement?
how do you execute a c program in unix.
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
What are identifiers in c?
Write programs for String Reversal & Palindrome check
write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...
using for loop sum 2 number of any 4 digit number in c language