Mega Code Archive

 
Categories / C / Language Basics
 

Compute the area of a triangle, given its width and height

#include <stdio.h> int main() {     char line[100];     int  height;     int  width;     int  area;     printf("Enter width height? ");     fgets(line, sizeof(line), stdin);     sscanf(line, "%d %d", &width, &height);     area = (width * height) / 2;     printf("The area is %d\n", area);     return (0); }