Friday, January 22, 2010

Task 1: solid, liquid or gas

Now is the correct time to do some task, because there are enough lessons posted before.
The task will be posted from this post until some following post.

Let’s begin.
Task 1:
Make a program, to decide whether the water is in form of solid (ice) or liquid or gas, according to the temperature.

Answer:
#include "iostream.h"
#include "conio.h"

main()
{
int temp;
cout<< "Form of Water";
cout<< "\n\nEnter the temperature (in celcious): ";
cin>>temp;
if (temp< 0)
cout<<"Solid";
else if (temp< 100)
cout<< "Liquid";
else
cout<< "Gas";
getch();
}

See the picture below as the result:
1. When a negative number was entered


2. When a number from 0 and 99 was entered


3. When number 100 or higher




0 comments:

Post a Comment