Here is the source code :
#include<iostream>
using namespace std;
int main()
{
int bil;
cout<<"input number: ";
cin>>bil;
if (bil<0)
{
cout<<"negative\n";
}
else if (bil==0)
{
cout<<"zero\n";
}
else
{
cout<<"positive\n";
}
system ("PAUSE");
return 0;
}
---***-----
i will analyze the meaning of that code.
#include<iostream> //is library to determine cin(input) and cout(output)
int main() //this is the main program that will be execute
#include<iostream> //is library to determine cin(input) and cout(output)
int main() //this is the main program that will be execute
int bil; //type is integer(number) and the name of variable is bil
cout <<"input number: "; //display "input number: " to screen
cin>>bil; //if user enters number, the program scan that number as "bil"
if (bil<0)
{
cout<<"negative\n";
}
// if value of bil is less than 0, program will display negative
else if (bil==0)
{
cout<<"zero\n";
}
// if value of bil is 0, program will display zero
else
{
cout<<"positive\n";
}
// if value of bil is other, program will display positive to the screen.
system ("PAUSE"); //system will pause until user press a key
return 0; //it will end main function and the return value is 0(the program run correctly)
}
run this program and this is the result:
hope this tutorial is useful. . Keep trying!
{
cout<<"negative\n";
}
// if value of bil is less than 0, program will display negative
else if (bil==0)
{
cout<<"zero\n";
}
// if value of bil is 0, program will display zero
else
{
cout<<"positive\n";
}
// if value of bil is other, program will display positive to the screen.
system ("PAUSE"); //system will pause until user press a key
return 0; //it will end main function and the return value is 0(the program run correctly)
}
run this program and this is the result:
hope this tutorial is useful. . Keep trying!