Advice On Computer Concepts - Programming Using C : Lesson 2
posted on 08/01/2009
In this article we will continue with our C lesson.
Structured Programming
C falls under the structured or modular programming category. Understanding the programming methodology is important before understanding the programming language since the language reflects the methodology that it is based upon.
'C' program depends largely on functions and getting things done by breaking the main problem into sub-problems. Consequently the main program in 'C' reflects this approach as it calls the functions to get parts of the problem done. Each function in turn calls other functions that it makes use of to realize the functionality that it wants to implement.
Comments
Comments are provided with the /* and */ brackets
/* This is a comment */
Basic Data Types
The basic data types available in 'C' language are
1. int - The integer for numbers
2. char - This data type stores characters and is useful to form strings
3. float - The data type which stores fractional numbers using floating point
4. double - For double precision in floating numbers
Examples
-----------------
int a;
char c;
float f;
double d;
a = 5;
c = 'h';
f = 2.1;
d = 3.141432567;
There is another data type which is called 'void' to specify that there is no data involved. It helps mostly to specify that the function does not return any data type or does not take in any data type as parameter (It is given as void)
void func (void); /* This function does not take any parameter or return anything */
Derived Data Types
1. Arrays - The basic data type can be extended to have an array of the same data type
2. Structures - This data type stores a set of like/different data types in a unit
3. Union - This data type stores like/different data types but uses common memory location for all of them
4. Pointers - This special data type stores the address of other data types
int array[10];
char string [] = "Hello World";
struct s
{
int i;
float f;
}
union u
{
int i;
char c;
};
Operators
The C language uses the lot many operators. The most common ones are given below.
Assignment operator (=)
All the mathematical operators are included like (+,-,*,/)
The special increment and decrement operators (++ and --)
Pointer related operations are the address of (&) and the value at (*)
The structure and union member access operators (-> and .)
Boolean operators (&,|,~,^)
Relational operators (&&,||,~,==)
Special operator (?:)
In the next article we will see a sample C program and the various parts of a C program



Comment on this article
You must be logged in to post comments.
Previous Comments