Archive for C Language

You are browsing the archives of C Language.

C Graphics

In a C Program first of all you need to initialize the graphics drivers on the computer. This is done using the initgraph method provided in graphics.h library.
Graphics mode Initialization
initgraph() function is used to load the graphics drivers and initialize the graphics system. For every function, that uses graphics mode, graphics mode must be initialized [...]

C Strings

Character type array is called string. All strings end with the NULL character. Use the %s placeholder in the printf() function to display string values.
Declaration:
char name[50];
Example

#include <stdio.h>
void main (void )
{
char *st1 = "abcd";
char st2[] = "efgh";
printf( "%s\n", s1);
[...]

C Pointers

A pointer is a variable suitable for keeping memory addresses of other variables; the values you assign to a pointer are memory addresses of other variables or other pointers.
C pointers are characterized by their value and data-type. The value is the address of the memory location the pointer points to, the type determines how the [...]

C Functions

Function is a block of statements which perform some specific task and always return single value to the calling function. Functions are used to minimize the repetition of code.
Some languages distinguish between functions which return variables and those which don’t. C assumes that every function will return a value. If the programmer wants a [...]

C Loops

Loops are used to repeat one statement or set statements more than one time. Most real programs contain some construct that loops within the program, performing repetitive actions on a stream of data or a region of memory. There are several ways to loop in C.
For Loop
For loop is a counter loop. The for loop [...]

C Control Structure

C language possesses such decision making capabilities and supports the following
statements known as control or decision-making statements.
if statement
switch statement
Conditional operator statement
goto statement
if Statement
The if statement is a powerful decision making statement and is used to control
the flow of execution of statements. It is basically a two-way decision statement
and is used in conjunction with an [...]

C Order of Precedence

It is necessary to be careful of the meaning of such expressions as a + b * c
We may want the effect as either
(a + b) * c
or
a + (b * c)
All operators have a priority, and high priority operators are evaluated before lower priority ones. Operators of the same priority are evaluated from [...]

C Operators

Arithmetic Operators
As well as the standard arithmetic operators (+ – * /) found in most languages, C provides some more operators. There are some notable differences with other languages, such as Pascal.
Assignment is = i.e. i = 4; ch = `y’;
Increment ++, Decrement — which are more efficient than their long hand [...]

C Keywords

Keywords:
A keyword is a word that is part of C Language itself. These words have predefined meanings and these words cannot be used as variable names.

C Keywords

char
signed
break [...]

C Constants

ANSI C allows you to declare constants. When you declare a constant it is a bit like a variable declaration except the value cannot be changed.
The const keyword is to declare a constant, as shown below:
int const a = 1;
const int a = 2;
Note:
• You can declare the const before or after the type. Choose [...]