Subscribe:

Ads 468x60px

Jumat, 10 Desember 2010

C LANGUAGE SYNTAX PROGRAM part I

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

0 comments:

Posting Komentar

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

Followers