C++ tutorial, C++ programs, C++ Exercises, C++ Example Programs

Friday, November 4, 2011

Program Temperature Conversion Algorithm Flowchart

Q: Write a C++ program To Convert Fahrenheit Temperature into Centigrade

Today, we will discuss a Program Temperature Conversion Algorithm Flowchart. This is a Three in One package for new C++ programmers for learning How To Program in C++. Let us see the algorithm first:


Algorithm: Temperature Conversion


This algorithm inputs a temperature in Fahrenheit and converts into centigrade.

1. Start
2. Input Temperature in Fahrenheit in F variable.
3. Calculate Centigrade C = (F-32) x 5.0 / 9.0   
4. Show temperature in centigrade
5. Stop


Picture of Temperature Conversion C++ Program With Sample Run Output

Image: Program Temperature Conversion Algorithm Flowchart

Program Temperature Conversion Algorithm Flowchart (Program code)

Flowchart of C++ Temperature Conversion Program

Image: ( Flow chart )Program Temperature Conversion Algorithm Flowchart

( Flow chart ) Program Temperature Conversion Algorithm Flowchart

Source code for DevC++ IDE/ C++ Compiler

#include<iostream> 

using namespace std;

int main()

{   

float c,f;

cout<< "Enter Temperature in F:";
cin>>f;
c=(f-32)*5.0/9.0;

cout<<"Temperature in centigrade="<<c;
return 0;
} 

Output

Enter Temperature in F:98.6
Temperature in centigrade=37
--------------------------------
Process exited after 16.38 seconds with return value 0
Press any key to continue . . .

C++ Source code Program Temperature Conversion

Sponsored Links



// include iostream.h header file

#include<iostream.h> 

// start of main function

int main()

{       // start of main function body
        // declare 2 float variables c and f

float c,f;

//show message to user to enter temperature in F
cout<< "Enter Temperature in F:";

//input temperature in F
cin>>f;

//calculate temperature in centi grade
c=(f-32)*5.0/9.0;

//show answer in centigrade
cout<<"Temperature in centigrade="<<c;

// return 0 - successful execution

return 0;
}     // end of main function body


So, beginners in C++ Programming, we have discussed how to design an algorithm, flow chart and write actual program code. Dear learners of C++, this is the end of this C++ tutorial on Program Temperature Conversion Algorithm Flowchart.

Simple Temperature Conversion program without comments C++ on Easyway C++

 //Turbo C++ 3.0 IDE Easyway C++ Programs
#include<iostream.h>
#include<conio.h>
void main()
{

float c,f;

cout<< "Enter Temperature in F:";

cin>>f;

c=(f-32)*5.0/9.0;

cout<<"Temperature in centigrade="<<c;

getche();
}


program-temperature-conversion-algorithm-flowchart-C-Plus-plus


Further Suggested Readings: After Download Free Turbo C++ Ver 3.0 IDE!

Basic Structure of a C++ Program

C++ Program Development Cycle

How To Write, Compile and Run Your First C++ Program

How To Start Turbo C++ IDE

How To Install Turbo C++ 3.0 - IDE

Features of C++ Programming Language

Brief History of C++

Flowcharts in Computer Programming

The Role of Algorithms in Programming

How To Start Computer Programming

What is a Computer Program

- See more at: http://easycppprogramming.blogspot.com
 < /b>

Share:

Program Average Algorithm and Flowchart

Q: Write a program to input three numbers, and calculate and show their average

Today, we will discuss a simple C++ program that inputs three numbers and calculates and shows average of these numbers.

Algorithm: Average

Calculates average of three numbers.

1. Start
2. Include iostream.h [Note: this step is only for C++].
3. Declare 5 float variables n1,n2,n3, total and avergae.
4. Display a message (prompt) on screen "Enter First Number:"
5. Input n1.
6. Display a message (prompt) on screen "Enter Second Number:"
7. Input n2.
7. Display a message (prompt) on screen "Enter Third Number:"
8. Input n3.
9. Calculate total= n1 + n2 + n3
10. Calculate average = total / 3
11. Show a message "Average=" and value stored in average variable.
12. Stop


C++ Program To Calculate Average of Three Numbers Input by User at Run time
C++ Program To Calculate Average of Three Numbers Input by User at Run time

Simple C++ Program To Calculate Average of Three Numbers With Algorithm and Flow chart
Simple C++ Program To Calculate Average of Three Numbers With Algorithm and Flow chart 

Source code for Dev C++ & other Modern C++ Compilers / IDEs

#include<iostream>
using namespace std;
int main()

{

float n1,n2,n3,total,average;
cout << "Enter First Number:";
cin>>n1;
cout<<"Enter Second Number:";
cin>>n2;
cout<<"Enter Third Number:";
cin>>n3;

total=n1+n2+n3;
average=total/3;

cout<<"average="<<average;
return 0;

}

A Sample Output of Program

Enter First Number:10
Enter Second Number:20
Enter Third Number:30
average=20
--------------------------------
Process exited after 26.5 seconds with return value 0
Press any key to continue . . .

Program Source Code for Turbo C++ 3.0: C++ Program To Calculate Average of Three Numbers With Algorithm and Flow chart

#include<iostream.h>

int main()

{

float n1,n2,n3,total,average;

cout << "Enter First Number:";

cin>>n1;

cout<<"Enter Second Number:";

cin>>n2;

cout<<"Enter Third Number:";

cin>>n3;

total=n1+n2+n3;

average=total/3;

cout<<"average="<<average;

return 0;

}

Share:

EasyCPPprogramming.blogspotcom

Labels