Archive for C First Program
You are browsing the archives of C First Program.
You are browsing the archives of C First Program.
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 [...]
A structure is a collection of variables under a single name. These variables can be of different types, and each has a name which is used to select it from the structure. A structure is a convenient way of grouping several pieces of related information together.
Declaring Structures
struct mystruct
{
int numb;
[...]
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);
[...]
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 [...]
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 has the following simple data types:
C type
Size (bytes)
Lower bound
Upper bound
Char
1
—–
——
Unsigned char
1
0
[...]
Here is your first c program. Write carefully because C Language is a case sensative language.
#include < stdio.h>
void main()
{
printf("Hello World\n");
}
Press ALT+F9 to compile your program. If you have any error in your program, you will get the message, remove your errors and then execute your program you will got the out [...]