Minggu, 05 September 2010

The If Statement in C language

Relational operators are used mainly to construct the relational expressions used in if and while statements, covered in detail on Day 6, "Basic Program Control." For now, I'll explain the basics of the if statement to show how relational operators are used to make program control statements.
You might be wondering what a program control statement is. Statements in a C program normally execute from top to bottom, in the same order as they appear in your source code file. A program control statement modifies the order of statement execution. Program control statements can cause other program statements to execute multiple times or to not execute at all, depending on the circumstances. The if statement is one of C's program control statements. Others, such as do and while, are covered on Day 6.

Operators in C language

An operator is a symbol that instructs C to perform some operation, or action, on one or more operands. An operand is something that an operator acts on. In C, all operands are expressions. C operators fall into several categories:
  • The assignment operator
  • Mathematical operators
  • Relational operators
  • Logical operators

Symbolic Constants

A symbolic constant is a constant that is represented by a name (symbol) in your program. Like a literal constant, a symbolic constant can't change. Whenever you need the constant's value in your program, you use its name as you would use a variable name. The actual value of the symbolic constant needs to be entered only once, when it is first defined.
Symbolic constants have two significant advantages over literal constants, as the following example shows. Suppose that you're writing a program that performs a variety of geometrical calculations.

Initializing Numeric Variables

When you declare a variable, you instruct the compiler to set aside storage space for the variable. However, the value stored in that space--the value of the variable--isn't defined. It might be zero, or it might be some random "garbage" value. Before using a variable, you should always initialize it to a known value. You can do this independently of the variable declaration by using an assignment statement, as in this example:

int count;   /* Set aside storage space for count */
count = 0;   /* Store 0 in count */

Variable Declarations in C language

Before you can use a variable in a C program, it must be declared. A variable declaration tells the compiler the name and type of a variable and optionally initializes the variable to a specific value. If your program attempts to use a variable that hasn't been declared, the compiler generates an error message. A variable declaration has the following form:

Numeric Variable Types

C provides several different types of numeric variables. You need different types of variables because different numeric values have varying memory storage requirements and differ in the ease with which certain mathematical operations can be performed on them. Small integers (for example, 1, 199, and -8) require less memory to store, and your computer can perform mathematical operations (addition, multiplication, and so on) with such numbers very quickly. In contrast, large integers and floating-point values (123,000,000 or 0.000000871256, for example) require more storage space and more time for mathematical operations. By using the appropriate variable types, you ensure that your program runs as efficiently as possible.
C's numeric variables fall into the following two main categories:

Make New Project C with Dev C++


How to make new project C with Dev C++ ? You dont know how to use Dev C++ ? or you have not Dev C++ ?
if you have not Dev C++ you can download that sofwtare Download Dev C++
After you download that software and install it
follow this step to make new project with Dev C++
First of all ,
  • Open Dev C++
  • Klik File 
  • New
  • Select Project
So, will be appear this dialog

  • Select console application
  • Select C project
  • And write you project name in field nam (space is not allowed)



  • And klik ok
  • So, now you must select directory, where you want to save your project. In this example i select directory in drive D:



  • Make new folder
  • Open folder and klik ok
  • So, you window will be appear like this


  • Now you can write your script
  • If you want to debug or run program click these icon



  • It is easy,isn't ?
  • You can make console aplication and GUI application and other with Dev C++

Disadvantages Of C Language

 C does have a few disadvantages. It is a terse language. Since C is a free-form language and does ot impose strict style rules, C programs cand be difficult to understand, especially if the programmer has not made the effrort to make the program readable.

What Advantages Of C Language ?

The C programming language has a number of advantages over other procedural language such as FORTAN, Pascal, and Basic. These include flexibility, efficiency,speed and portability. C is very powerful and flexibel language. This is evident from the fact that C is being used extensively for developing a wide variety of aplication. Some of advantages of the C programming language are listed in the paragraphs that follow

First C program (Hello.c)

You’re probably eager to try your first program in C. To help you become familiar with your compiler, here’s a quick program for you to work through. You might not understand everything at this point, but you should get a feel for the process of writing, compiling, and running a real C program.

A Brief History of the C Language

You might be wondering about the origin of the C language and where it got its name. C was created by Dennis Ritchie at the Bell Telephone Laboratories in 1972. The language wasn’t created for the fun of it, but for a specific purpose: to design the UNIX operating system (which is used on many computers). From the beginning, C was intended to be useful–to allow busy programmers to get things done.

Software For C Compiler

For compiling the source code of c/c++ you must have compiler, there are many compiler such as DEV C++, QT3, Visual C++, Tiny C Compiler, Miracle C Compiler, Borland C++.
  1. DOWNLOAD DEV C++
  2. DOWNLOAD QT3
  3. DOWNLOAD VISUAL C++
  4. DOWNLOAD TINY C COMPILER
  5. DOWNLOAD MIRACLE C COMPILER
  6. DOWNLOAD BORLAND C++

Keywords Of C Language

The words int and float are C keywords. C keywords are the words that form the language. All C keywords are in lowercase. The C language keywords are
auto     -  double  - inline   - static
 break    -  else    - int      - struct
 case     -  enum    - long     - switch
 char     -  extern  - register - typedef
 complex  -  float   - restrict - union
 const    -  for     - return   - unsigned
 continue -  goto    - short    - void
 default  -  if      - signed   - volatile
 do       -  sizeof  - while    - imaginary
Keywords cannot be used for any other purpose in a C program, that is, they may not be used as variable names or function names