0% found this document useful (0 votes)
52 views

Mathematical Programming in C

This document contains 5 C++ programs that demonstrate mathematical programming concepts: 1) A program to calculate the area of a triangle given the lengths of its three sides. 2) Another program to calculate the area of a triangle given its base and height. 3) A program to convert temperatures from Celsius to Fahrenheit. 4) A program to reverse three input numbers. 5) A program to calculate the sum, product, and average of four input numbers.

Uploaded by

M Noaman Akbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Mathematical Programming in C

This document contains 5 C++ programs that demonstrate mathematical programming concepts: 1) A program to calculate the area of a triangle given the lengths of its three sides. 2) Another program to calculate the area of a triangle given its base and height. 3) A program to convert temperatures from Celsius to Fahrenheit. 4) A program to reverse three input numbers. 5) A program to calculate the sum, product, and average of four input numbers.

Uploaded by

M Noaman Akbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

MATHEMATICAL

PROGRAMMING IN C++
PREPARING BY TAHIR KHAN FARYAD , M. NOAMAN AKBAR ,
SIDRA RAZZAQ

1 - Area of Triangle:#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,s,area;
cout<<"enter the values"<<endl;
cin>>a>>b>>c;
s=(a+b+c)/2;
cout<<"s is ="<<

s;

area=sqrt(s*(s-a)*(s-b)*(s-c));
cout<<"area of triangle is "<<area<<endl;
getch();
}

2 - Area of Triangle:#include<iostream.h>
#include<conio.h>
void main()
{

float area,base,hight; cout<<"enter the value of base ";


cin>>base
cout<<"eter the value of hight ";
cin>>hight;
area=0.5*base*hight;
cout<<"Area of triangal is"<<" = "<<area<<endl;
getch();
}

3 - Temperture:#include<iostream.h>
#include<conio.h>
void main()
{
float f,c;
cout<<"enter the temprature";
cin>>c;
f=1.8*c+32;
cout<<"temrature in fahrenheit"<<"="<<f<<endl;
getch();
}

4 - Reverse:#include<iostream.h>
#include<conio.h>
void main()
{

int a,b,c;
cout<<"enter the numbers"<<endl;
cin>>a>>b>>c;
cout<<"revers"<<c<<b<<a;
getch();
}

5 - Sum:#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c,d, sum,prd,avg;
cout<<"enter the values"<<endl;
cin>>a>>b>>c>>d;
sum=a+b+c+d;
cout<<"sum is "<<sum;
prd=a*b*c*d;
cout<<"\nproduct is "<<prd;
avg=(a+b+c+d)/4;
cout<<" \navreg is "<< avg<<endl;
getch();
}

You might also like