C Program To Find The Area Of Triangle Using Base And Height

Studytonight is now part of the GUVI universe. Explore GUVI → 🤩 New Cool Developer Tools for you. Explore → FREE JavaScript Video Series Start Learning → Signup/Sign In
    Dark Mode On/Off
Interactive LearningInteractive Learning C Language course GO Lang course Learn JavaScript Learn HTML Learn CSS C LangC Language C Tutorial C Programs (100+) C Compiler Execute C programs online. CppC++ Language C++ Tutorial Standard Template Library C++ Programs (100+) C++ Compiler Execute C++ programs online. PythonPython Python Tutorial Python Projects Python Programs Python How Tos Numpy Module Matplotlib Module Tkinter Module Network Programming with Python Learn Web Scraping More in Python... Python Compiler Execute Python code online. JavaJava Core Java Tutorial Java Programs (100+) Java Code Examples (100+) Servlet JSP - Java Server Pages Java Type Conversion Examples Java Wrapper Class Spring Framework Java 11 More in Java... Java Compiler Execute Java code online. CAOComputer Sci. (GATE) Operating System Computer Architecture Computer Network DBDatabase DBMS Learn SQL MongoDB PL/SQL Practice SQL Execute SQL Queries online. More Tutorials... AndroidAndroid KotlinKotlin Game DevGame Development GO LanguageGO Language GIT GuideGIT Guide Linux GuideLinux Guide DockerDocker Spring FrameworkSpring Boot PHPPHP HTML TagsHTML Tags (A to Z) CSSCSS JavascriptJavaScript SASSSASS/SCSS Tests MCQs to test your knowledge. Compilers Compilers to execute code in browser.
  • Learn to Code
    • Interactive Courses, where you Learn by writing Code.
    • C LanguageC Language NEW
    • GO LangGO Language NEW
    • JavascriptJavaScript
    • CSSCSS
    • HTMLHTML
    • Projects/Concept Bundles
  • Library C Lang C Language

    C TUTORIAL

    Overview of C Language

    Compile & Run C Code

    What are Variables?

    C Operators (with Examples)

    See all →

    C PROGRAMS

    Armstrong Number Program

    Check Number is Odd/Even

    First n Prime Numbers

    Reverse String using Pointer

    See all Programs (100+) →

    INTERVIEW TESTS

    MCQs to test your C language knowledge.

    C Tests →

    EXECUTE CODE

    Run C programs and code examples online.

    C Compiler → Cpp C++ Language

    C++ TUTORIAL

    C++ Datatypes and Modifiers

    sizeof and typedef

    Create Class and Object

    See all →

    C++ PROGRAMS

    Check if Number is Positive/Negative

    Half Pyramid with Numbers

    Floyd's Triangle

    See all Programs (100+) →

    Data Structures → Standard Template Library → Advanced Data Structures →

    INTERVIEW TESTS

    MCQs to test your C++ language knowledge.

    C++ Tests →

    EXECUTE CODE

    Run C++ programs and code examples online.

    C++ Compiler → Python Python

    PYTHON TUTORIAL

    Python Installation & Setup

    Concept of OOP & Class

    Access Modifiers

    Python Projects →

    PYTHON HOW TOS

    Print Colored Text in Python

    Remove Numbers from String

    Compare two Dates

    See all How Tos (80+) →

    Tkinter → Matplotlib → NumPy → Python Programs → Network Programming → Web Scraping →

    INTERVIEW TESTS

    MCQs to test your Python knowledge.

    Python Tests →

    EXECUTE CODE

    Run Python code examples in browser.

    Python Compiler → Java Core Java JAVA TESTS MCQs to test your Java knowledge. EXECUTE JAVA CODE Run Java code in browser.

    JAVA TUTORIAL

    Setting Java Environment

    Concept of Constructor

    See all →

    JAVA CODE EXAMPLES

    Running a JAR File

    Serialization and Deserialization

    See all Examples (80+) →

    Spring Framework SPRING TUTORIAL

    Spring Framework

    Spring Boot

    Spring Security

    MORE IN JAVA

    Java Library Functions

    Type Conversion Examples

    Java 11 Features

    See all →

    Computer Science Computer Science

    CAO COMPUTER ARCHITECTURE

    Basics Of Digital Components

    Different type of Logic gates

    Memory organization

    See all →

    Computer Network COMPUTER NETWORK

    Types of Computer Networks

    Transmission Mediums

    ISO/OSI model

    See all →

    Operating System OPERATING SYSTEM

    Types of Operating System

    Process Scheduling

    CPU Scheduling

    First come First Serve

    Shortest Job First

    Classical Synchronization Problem

    What are Semaphores?

    What are Deadlocks?

    See all →

    DBMS Database

    DBMS & SQL

    ER Model

    Relational Algebra & Calculus

    Types of DBMS Keys

    Database Normalization

    See all →

    PL/SQL

    Datatypes in PL/SQL

    PL/SQL Procedures

    How to create Cursor?

    See all →

    MongoDB

    MongoDB vs. RDBMS

    Installing MongoDB

    Using MongoDB with Java

    See all →

    EXECUTE SQL

    Practice SQL Query in browser with sample Dataset.

    Run SQL Query → (Learn SQL Queries) More...

    AndroidANDROID DEVELOPMENT

    GOGO LANGUAGE

    linuxLINUX

    dockerDOCKER

    HTMLHTML TAGS (A to Z)

    cssCSS REFERENCES

    sassSASS/SCSS

    kotlinKOTLIN

    unity 3dGAME DEVELOPMENT

    phpPHP

    gitGIT GUIDE

    javascriptJAVASCRIPT

    dsaADVANCED DSA

  • Tests
  • CoursesNEW
coins 500 coins Login Pandas SASS/SCSS JavaScript Spring Boot HTML 5 References Docker Python Built-in Functions Kotlin C++ Programs Java Examples Java 8 Tkinter Elasticsearch GIT Guide Linux Guide Matplotlib Java 9 Java Wrapper Classes Index Explore: Tutorials Library MCQ Tests Curious? Learn Coding!
  • Basic Programs

    • Hello World
    • Taking Input from User
    • Find ASCII Value of Character
    • Using gets() function
    • If-Else
    • Switch Case
    • Checking for Vowel
    • Reversing Case of Character
    • Swapping Two Numbers
    • Largest and Smallest using Global Declaration
  • Loop

    • Basic for Loop
    • Basic while Loop
    • Basic do-while Loop
    • Nested for Loops
    • Program to find Factorial of number
    • Fibonacci Series Program
    • Palindrome Program
    • Program to find Sum of Digits
    • Program to reverse a String
  • Numbers

    • Program to find Average of n Numbers
    • Armstrong Number
    • Checking input number for Odd or Even
    • Print Factors of a Number
    • Find sum of n Numbers
    • Print first n Prime Numbers
    • Find Largest among n Numbers
    • Exponential without pow() method
    • Find whether number is int or float
    • Print Multiplication Table of input Number
  • Arrays

    • Reverse an Array
    • Insert Element to Array
    • Delete Element from Array
    • Largest and Smallest Element in Array
    • Sum of N Numbers using Arrays
    • Sort Array Elements
    • Remove Duplicate Elements
    • Sparse Matrix
    • Square Matrix
    • Determinant of 2x2 matrix
    • Normal and Trace of Square Matrix
    • Addition and Subtraction of Matrices
    • Matrix Mulitplication
  • Pointer

    • Simple Program
    • Memory Management
    • Array of Pointers
    • Pointer Increment and Decrement
    • Pointer Comparison
    • Pointer to a Pointer
    • Concatenate Strings using Pointer
    • Reverse a String using Pointer
    • Swapping Two Numbers
    • Pointer to a Function
    • Null Pointer
  • ctype.h

    • islower()
    • isupper()
    • tolower()
    • toupper()
    • isalpha()
    • isalnum()
    • isspace()
    • ispunct()
    • isgraph() and isprint()
  • String

    • strcpy()
    • strcmp()
    • strrev()
    • Removing Whitespaces
    • gets() and strlen()
    • strlen() and sizeof()
    • Frequency of characters in string
    • Count Number of Vowels
  • Recursion

    • Adding Two Numbers
    • Factorial
    • Fibonacci Series
    • Sum of First N Numbers
    • Sum of Digits
    • Palindrome
    • Power of N
    • Largest Array Element
    • Prime or Composite
    • LCM of Two Numbers
    • GCD of Two Numbers
    • Reverse a String
  • Files and Streams

    • List Files in Directory
    • Size of File
    • Write in File
    • Reverse Content of File
    • Copy File to Another File
  • Important Concepts

    • Leap Year
    • Largest of three numbers
    • Second largest among three numbers
    • Adding two numbers using pointers
    • Sum of first and last digit
    • Area and Circumference of Circle
    • Area of Triangle
    • Basic Arithmetic Operations
    • Conversion between Number System
    • Celsius to Fahrenheit
    • Simple Interest
    • Greatest Common Divisor(GCD)
    • Roots of Quadratic Roots
    • Identifying a Perfect Square
    • Calculate nPr and nCr
  • Miscellaneous

    • Windows Shutdown
    • Without Main Function
    • Menu Driven Program
    • Changing Text Background Color
    • Current Date and Time
C Program to find the Area of Triangle using Base and Height

Below is a program to find the area of triangle using base and height.

#include<stdio.h> int main() { printf("\n\n\t\tStudytonight - Best place to learn\n\n\n"); int h, b; float area; printf("\n\nEnter the height of the Triangle: "); scanf("%d", &h); printf("\n\nEnter the base of the Triangle: "); scanf("%d", &b); /* Formula for the area of the triangle = (height x base)/2 Also, typecasting denominator from int to float to get the output in float */ area = (h*b)/(float)2; printf("\n\n\nThe area of the triangle is: %f", area); printf("\n\n\t\t\tCoding is Fun !\n\n\n"); return 0; }

Output:

C program output for Area of Triangle using Base and Height

Program to find the Area of Triangle using Heron's Formula

Below is a program to find the area of triangle using heron's formula.

#include<stdio.h> #include<math.h> // to use sqrt() function int main() { printf("\n\n\t\tStudytonight - Best place to learn\n\n\n"); double a, b, c, area, s; printf("\nEnter the sides of the triangle:\n\n"); scanf("%lf%lf%lf", &a, &b, &c); // lf is format specifier for double input s = (a+b+c)/2; /* sqrt is a predefined system function that returns the square root of the input value */ area = sqrt(s*(s-a)*(s-b)*(s-c)); printf("\n\n\n\nThe area of the Triangle calculated using Heron's formula is: %lf", area); printf("\n\n\t\t\tCoding is Fun !\n\n\n"); return 0; }

Output:

C Program output for Area of Triangle using Heron's formula

  • ← Prev
  • Next →

C Lang C Tutorial

Best tutorial for beginners. Explore

C MCQ Tests

Prepare for TCS, Infosys, etc. Explore

Tag » Area Of Triangle C Code