Program to Accept value of base & height and Calculate Area of Triangle c++ program in hindi

Area of Triangle C++ Program in Hindi

Area of Triangle C++ Program in Hindi

समस्या को समझना:-

हमें एक ऐसा प्रोग्राम लिखना होता है जो यूजर से त्रिभुज की तीन भुजाओं को स्वीकार करता है और उसके क्षेत्रफल को प्रिंट करता है। दिए गए तीन पक्षों से त्रिभुज के क्षेत्रफल की गणना करने के लिए, हम हीरोन के सूत्र का उपयोग करते हैं|

Area = √ s*(s-a)*(s-b)*(s-c),

जहाँ s = (a+b+c)/2

Algorithm

  1. उपयोगकर्ता से त्रिभुज की तीनों भुजाओं का इनपुट लें और उन्हें वेरिएबल्स a, b और c में स्टोर करें।
  2. अब फ्लोट प्रकार का एक वेरिएबल घोषित करें और इसमें आधा परिधि की गणना करें और स्टोर करें। (स्पष्ट टाइपकास्टिंग का उपयोग करना न भूलें क्योंकि ‘s’ फ्लोट प्रकार का है और a, b, c int हैं)
  3. फ्लोट प्रकार का एक वेरिएबल क्षेत्र घोषित करें और इसमें दिए गए सूत्र का उपयोग करके त्रिकोण के क्षेत्र की गणना करें और स्टोर करें।
  4. प्रिंट क्षेत्र।

इसी प्रकार निचे दिए गये code को देखे और समझे | code किस प्रकार काम कर रहा है,

Code:

#include <iostream>
#include<cmath> //to use sqrt function
using namespace std;

int main()
{
  int a,b,c; //taking input of the three sides from the user

    cout << "Enter the three sides of the triangle\n";

    cin>>a>>b>>c;

    float s=(float)(a+b+c)/2; //calculating s

    float area=sqrt(s*(s-a)*(s-b)*(s-c)); //calculating area

    cout<<"Area="<<area; //printing the area

    return 0;

}

Output :-

Enter the three sides of the triangle:
5 10 12
Area = 24.5446

ये भी पढ़े :-

C++ प्रोग्राम दो नंबर स्वैप केसे करे |

C++ language syllabus in Hindi (object oriented programming c++ syllabus)

Previous articlewhere is the C programming language used?|c basic interview questions.
Next articleWho developed C language?|c interview questions and answers for freshers

LEAVE A REPLY

Please enter your comment!
Please enter your name here