RSS

Preparation before making a C program

31 Aug

Before starting the program language C we must know first dong function – the function to create a C program, but first please excuse me if there is something missing because I was still a beginner in programming C,
1. Header okay for C programming that will be discussed this blog will mostly use standard input output header (stdio.h) is usually to write header in C programming is <stdio.h> or # include # include “stdio.h” the difference is

include <stdio.h> -> stdio.h exists in the location that is known to the compiler, usually the default compiler library while

include “stdio.h” -> stdio.h is in locations outside the compiler

2. play the program can say it is the framework of C programming (also called play Melepasmu program) nah play normally declared within a variable or output or expenditure related principally the main program deh …

okay after tau components – components for C programming now how to declare a variable, in the C language, a variable before compiling will be declared the variable to store what?? instance variable “a” to store an integer, then the A to be declared beforehand by writing int a; okay variables can store any kind of hell?? what wrote boleeeh-_-

Okay variable can store

character -> declared with char

string -> string declared

integers -> declared with int

coma numbers -> declared with float

masihbanyak true, but this is an important first, hehehehe okay there are examples of simple program

# Include <stdio.h>

main ()

{

printf (“congratulations learn C”);

getchar ();

return 0;

}

results if compiled is

 

okay it was just a simple program that displays the output ‘good learning C “, and there is no declaration of variables there, well now is a simple program to add up the numbers one to another number

# Include <stdio.h>

main ()

{

int a, b;

printf (“enter the first number:”);

scanf (“% d”, & a); getchar ();

printf (“enter the second number:”);

scanf (“% d”, & b); getchar ();

printf (“the result of% d +% d is% d”, a, b, (a + b));

getchar ();

return 0;

Okay} algorithm above is a simple summation algorithm, I will describe the algorithm of the above, okay first, as always wrote his header and play like the first one, right after that do not forget to open the curly braces, now declare the variables a and b it to a variable integer, then the program will display the screen it says “enter the first number” well when you are on now number over there then the number will be stored in a variable in decimal, with scanf functions, as well as for the second number, then after the first number and the second number complete input, then the program will display the screen “the result of% d +% d is% d”% d is now what hayoooo, yep the integer% d, now what dikeluarin integer, so after the quotation marks there continues a comma, b, (a + b)% d finished first for value in a variable a,% d second for the value of the variable b% d and for the latter to the value of (a + b), simple right? hhehehe ok if compiled in dev C would be like this

NB:

% D for integers

% C for character

% F for floating point

% S for strings

 
Leave a comment

Posted by on August 31, 2012 in Technology Information

 

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: