PART I ==> simple calculator
# include <stdio.h>
# include <conio.h>
main ()
{
float x, y, add, less, times, for;
printf ("\ t PROGRAM CALCULATOR \ n");
printf ("Input number # 1:"); scanf ("% f", & x);
printf ("Input number # 2:");
scanf ("% f", & y);
added = x + y;
less = x-y;
time = x * y;
for = x / y;
printf ("\ n Results% .1 f +% .1 f =% .1 f", x, y, add);
printf ("\ n Results% .1 f -% .1 f =% .1 f", x, y, or less);
printf ("\ n Results% .1 f x% .1 f =% .1 f", x, y, time);
printf ("\ n Results% .1 f:% .1 f =% .2 f", x, y, for);
printf ("\ n Results% .1 f% c =% .1 f \ n", x, 1, sqrt (x));
getch ();
}
Save with the extension. C
Display program
CALCULATOR PROGRAM
Input number into-1 : 4
Input numbers into-2 : 5
Results 4.0 + 5.0 = 9.0
Results 4.0 - 5.0 = -1.0
Results 4.0 X 5.0 = 20.0
Results 4.0 : 5.0 = 0.80
Results 4.0 ☺ = 2.0
Description of program:
The program above will perform simple arithmetic functions on figures that have been fed. As already described in the previous tutorial, that the function of 'printf ()' which is to display the output to the screen and the function 'scanf ()' for reading the input data. Operators are in use in the above program is the addition operator (+), reduction (-), multiplication (x), division (:) and the square root ( smile ) hehehee,, sorry I have not met the square root ascii code. OK ..., it seems easy enough until here ... to deepen knowledge in C programming language, you can see in my next tutorial,, see you ....!
Download as PDF
As already described in the previous tutorial, the compiler is the translator source code into machine language to be recognized by the computer. One of the compiler that can be used is GCC, here I'll explain how to compiler GCC can be used well on your computer.
For windows 7 :
- Download file GCC compiler which is known by the name of MinGW.
- Then install into your PC .
- When the installation is placed on drive C: (not in program files)
ex : C:\MinGW Ex รจ C: \ MinGW
- Then right click on my computer ==> properties
- Select advanced
- In advenced dialog box, click the environment variables
- In the system variables, double click the path variables
- Type (C: \ MinGW \ bin), do not forget to add a semicolon (;) before the letter C
- Restart your PC
To use it:
1. Open a commend prompt
2. open the drive where you put the file C that you created.
3. Type (gcc *****.c -o *****.exe)
example : ( gcc calculator.c –o calculator.exe )
4. Your program is ready for use.
Note: (****) extention file name .c
download MinGW whitout Installer here...
In the programming c used the function "scanf ()" to read input in the insert, and fungis "printf ()" to display the results entered.
Here is a list of formats for input.
Quote of the Day
if we plant the rice then it is definitely going to grow grass
but if we do not expect to plant grass to grow rice
if we do that then the world will follow hereafter
but if we do that the world then the afterlife will not participate