See the programming language C


Each program must have a starting point. When you run a program, DOS sends it off on its way — like launching a ship. As its last dock-master duty, DOS hurls the microprocessor headlong into the program. The microprocessor then takes the program's helm at that specific starting point.
In all C programs, the starting point is the main() function. Every C program has one, even GOODBYE.C (shown in Figure 1). The main() function is the engine that makes the program work, which displays the message on the screen.


Figure 1: GOODBYE.C and its pieces and parts.
Other C programs may carry out other tasks in their main() function. But whatever's there, it's the first instruction given to the computer when the program runs.
  • main() is the name given to the first (or primary) function in every C program. C programs can have other functions, but main() is the first one.
  • It's a common convention to follow a C language function name with parentheses, as in main(). It doesn't mean anything. Everyone does it, and it's included here so that you don't freak when you see it elsewhere.
  • In Borland C++, you may have seen the error message say "in function main." This message refers to the main function — the void main() thing that contains the C language instructions you've been writing.
  • A function is a machine — it's a set of instructions that does something. C programs can have many functions in them, though the main function is the first function in a C program. It's required.
Function. Get used to that word.

Pieces' parts

Here are some interesting pieces of the C program shown in Figure 1:
1. #include is known as a preprocessor directive, which sounds impressive, and it may not be the correct term, but you're not required to memorize it anyhow. What it does is tell the compiler to "include" another program or file along with your source code, which generally avoids a lot of little, annoying errors that would otherwise occur.
2. <stdio.h> is a filename hugged by angle brackets (which is the C language's attempt to force you to use all sorts of brackets and whatnot). The whole statement #include <stdio.h> tells the compiler to use the file STDIO.H, which contains standard I/O, or input/output, commands required by most C programs.
3. void main identifies the name of the function main. The void identifies the type of function or what the function produces. In the case of main, it doesn't produce anything, and the C term for that is "void."
4. Two empty parentheses follow the function name. Sometimes, there may be items in these parentheses.
5. The curly brackets or braces enclose the function, hugging in tight all its parts. Everything between { and } is part of the function main() in Figure 1.
6. printf is a C language instruction, part of the programming language that eventually tells the computer what to do.
7. Belonging to printf are more parentheses. In this case, the parentheses enclose text, or a "string" of text. Everything between the double quotes (") is part of printf's text string.
8. An interesting part of the text string is \n. That's the backslash character and a little n. What it represents is the character produced by pressing the Enter key. What it does is to end the text string with a "new line."
9. Finally, the printf line, or statement, ends with a semicolon. The semicolon is how the C compiler knows when one statement ends and another begins — like a period at the end of a sentence. Even though printf is the only instruction in this program, the semicolon is still required.
• Text in a program is referred to as a string. For example, "la-de-da" is a string of text. The string is enclosed by double quotes.
• The C language is composed of keywords that appear in statements. The statements end in semicolons, just as sentences in English end in periods.)

The C language itself — the keywords

The C language is really rather brief. There are only 33 keywords in C. If only French were that easy! Table 1 shows the keywords that make up the C language.

Table 1: C Language Keywords
asm
enum
signed
auto
extern
sizeof
break
float
static
case
for
struct
char
goto
switch
const
if
typedef
continue
int
union
default
long
unsigned
do
register
void
double
return
volatile
else
short
while
Not bad, eh? But these aren't all the words you find in the C language. Other words or instructions are called functions. These include jewels like printf and several dozen other common functions that assist the basic C language keywords in creating programs.
If you're using DOS, additional functions specific to DOS are piled on top of the standard C armada of functions. And if you get into Windows, you find hoards of Windows-specific functions that bring C's full vocabulary into the hundreds. And no, you don't really have to memorize any of them. This is why all C compilers come with a language reference, which you'll undoubtedly keep close to your PC's glowing bosom.
Languages are more than a collection of words. They also involve grammar, or properly sticking together the words so that understandable ideas are conveyed. This concept is completely beyond the grasp of the modern legal community.
In addition to grammar, languages require rules, exceptions, jots and tittles, and all sorts of fun and havoc. Programming languages are similar to spoken language in that they have various parts and lots of rules.
  • You will never be required to memorize the 33 keywords.
  • In fact, of the 33 keywords, you may end up using only half on a regular basis.
  • Some of the keywords are real words! Others are abbreviations or combinations of two or more words. Still others are cryptograms of the programmer's girlfriends' names.
  • Each of the keywords has its own set of problems. You don't just use the keyword else, for example; you must use it in context.
  • Functions like printf require a set of parentheses and lots of stuff inside the parentheses. (Don't fret over this right now; just nod your head and smile in agreement, "Yes, printf does require lots of stuff.")
  • By the way, the fact that printf is a C function and not a keyword is why the #include <stdio.h> thing is required at the beginning of a program. The STDIO.H file contains the instructions telling the compiler what exactly printf is and does. If you edit out the #include <stdio.h> line, the compiler produces a funky "I don't know that printf thing" type of error.

understanding of programming Declaring Variables in C


Variables are what make your programs zoom. Programming just can't get done without them. So if you haven't been introduced to variables yet, here you go.
Valerie Variable is a numeric variable. She loves to hold numbers — any number; it doesn't matter. Whenever she sees an equal sign, she takes to a value and holds it tight. But see another equal sign, and she takes on a new value. In that way, Valerie is a little flaky. You could say that Valerie's values vary, which is why she's a variable.
Victor Variable is a string variable. He contains bits of text — everything from one character to several of them in a row. As long as it's a character, Victor doesn't mind. But which character? Victor doesn't care — because he's a variable, he can hold anything.
  • Yes, there is a point here. There are two main types of variables in C: numeric variables that hold only numbers or values, and string variables that hold text, from one to several characters long.
  • There are several different types of numeric variables, depending on the size and precision of the number.
  • Before you use a variable, it must be declared. This is — oh, just read the next section.

"Why must I declare a variable?"

You are required to announce your variables to the C compiler before you use them. You do this by providing a list of variables near the beginning of the program. That way, the compiler knows what the variables are called and what type of variables they are (what values they can contain). Officially, this process is known as declaring your variables.
For example:
int count;
char key;
char lastname[30];
Three variables are declared here: an integer variable, count; a character variable, key; and a character variable, lastname, which is a string that can be as many as 30 characters long.
Doing this at the beginning of the program tells the compiler several things. First, it says, "These things are variables!" That way, when the compiler sees lastname in a program, it knows that it's a string variable.
Second, the declarations tell the compiler which type of variable is being used. The compiler knows that integer values fit into the count variable, for example.
Third, the compiler knows how much storage space to set aside for the variables. This can't be done "on the fly" as the program runs. The space must be set aside as the compiler creates the program.
  • Declare your variables near the beginning of your program, just after the line with the initial curly bracket. Cluster them all up right there.
  • Obviously, you won't know all the variables a program requires before you write it. (Although they teach otherwise at the universities, such mental overhead isn't required from you.) So, if you need a new variable, use your editor to declare it in the program. Rogue variables generate syntax or linker errors (depending on how they're used).
  • If you don't declare a variable, your program does not compile. The proper authorities issue a suitable complaint message.
  • Most C programmers put a blank line between the variable declarations and the rest of the program.
  • There's nothing wrong with commenting a variable to describe what it contains. For example:
int count; /* busy signals from tech support. */
  • However, cleverly named variables may avoid this situation:
int busysignals;

Variable names verboten and not

What you can name your variables depends on your compiler. There are a few rules, plus some names you cannot use for variables. When you break the rules, the compiler lets you know by flinging an error at you. To avoid that, try to keep the following guidelines in the back of your head when you create new variables:
  • The shortest variable name is a letter of the alphabet.
  • Use variable names that mean something. Single-letter variables are just hunky-dory. But index is better than i, count is better than c, and name is better than n. Short, descriptive variable names are best.
  • Variables are typically in lowercase. (All of C is lowercase for the most part.) They can contain letters and numbers.
  • Uppercase letters can be used in your variables, but most compilers tend to ignore the differences between upper- and lowercase letters. (You can tell the compiler to be case-sensitive by setting one of its options; refer to your programmer's manual.)
  • You should not begin a variable name with a number. They can contain numbers, but you begin it with a letter.
  • C lords use the underline, or "underscore," character in their variable names: first_name, zip_code, and so on. This technique is fine, though it's not recommended to begin a variable name with an underline.
  • Avoid naming your variables the same as C language keywords or functions. Don't name your integer variable int, for example, or your string variable char. This may not generate an error with your compiler, but it makes your source code confusing.
  • Also avoid using the single letters l (lowercase L) and o (lowercase O) to name variables. Little L looks too much like a 1 (one), and O looks too much like a 0 (zero).
  • Don't give similar names to your variables. For example, the compiler may assume that forgiveme and forgivemenot are the same variable. If so, an ugly situation can occur.
  • Buried somewhere in one of the massive tomes that came with your compiler are the official rules for naming variables. These rules are unique to each compiler.

simple explanation for float and int

Greetings blogger friends healthy this time I wrote an article titled explanation float and int.

Of the headache thinking about the task better sit stacked in depen laptop to a friend for sharing semua.Yang first to know that int is short for integer that is to receive the data in the form of numbers like 1,2,3,4,5. While float receive data 1.5,3.4,5.6 be essentially used to execute more details float and int numbers desiimal numbers for sure.

See an example of a simple program that I created using int as below:

#include<stdio.h>
main() {

int c,d ;

printf("masukkan bilangan 1 = ");
scanf("%d",&c);

printf("masukkan bilangan 2 = ");
scanf("%d",&d);

printf("\nhasil = %d\n",c + d);

return 0 ;

}


will produce output like this:

whereas example a simple program to use float:
#include<stdio.h>
main() {

float c,d ;

printf("masukkan bilangan 1 = ");
scanf("%f",&c);

printf("masukkan bilangan 2 = ");
scanf("%f",&d);

printf("\nhasil = %f\n",c + d);

return 0 ;

}

and will generate output like this:

Good luck

how to create a multiplication program in C

healthy greeting for this time my blogger friend wrote an article titled how to make multiplication program in C. Codding is only made ​​when cranky because confusion and dizziness makaknya so cranky Codding hehehe. . okeh just the way it is quite easy

Her logic: If we enter a number it will show the number of multiplication.
#include<stdio.h>
main() {
int a;

printf("masukkan bilangan = ");
scanf("%d",&a);

printf(" 1  x %d = %d\n",a,1*a);
printf(" 2  x %d = %d\n",a,2*a);
printf(" 3  x %d = %d\n",a,3*a);
printf(" 4  x %d = %d\n",a,4*a);
printf(" 5  x %d = %d\n",a,5*a);
printf(" 6  x %d = %d\n",a,6*a);
printf(" 7  x %d = %d\n",a,7*a);
printf(" 8  x %d = %d\n",a,8*a);
printf(" 9  x %d = %d\n",a,9*a);
printf(" 10 x %d = %d\n",a,10*a);
return 0 ;

}
The output results as shown below:
output  
Good Luck

bertukar link sahabat

Apakah sobat blogger ingin bertukar link??  Untuk menyambung silaturrahmi antar sesama blogger yang baik hati silahkan sobat copy script di bawah ini. Jika sobat sudah memasang link ini di blog sobat silahkan beritahukan kepada saya melalui kotak komentar sehingga saya bisa tau bahwa link saya sudah terpasang di blog sobat dan saya akan segera mengkonfirmasi link sobat.





 Link untuk teks 
 copy lalu paste link ini di widget blog anda



<a href="http://jahetrepcom.blogspot.com/" target="_blank" title="Belajar Blog|Komputer|Internet|Informasi terupdate"> <blink><b>Codding Ngambek</b></blink> </a>



Terima Kasih atas kunjungan sobat dan saya berharap silaturrahmi antar sesama blogger selalu terjaga

by jahet repcom