Category: Fundamentals of C Programming

Introduction to C programming 97

Introduction to C Programming Language

C programming is a language developed by AT & T’s Bell Laboratories of USA in 1972. It was designed and written by a man named Dennis Ritchie. C language is reliable, simple and easy to use. It has survived for more than 4 decades. This language is a base to learn different programming language. If you want to learn C++ or JAVA, without the knowledge of C, it becomes very difficult to learn these programming languages. Many major components of popular operating systems like Windows, UNIX, LINUX are still written in C. Nothing beats C language in terms of speed...

C Programming Constants, Variables and Keywords 53

Variable, Constant and Keyword in C

Variable, constant or keyword in C can be formed from any combination of Alphabets, Digits and Special Symbols. A constant in C programming is an entity whose value does not change throughout the program execution. A variable in C is an entity whose value keeps on changing throughout the program execution. However, it’s not a rule that the value of the variable will change. A variable in C value might remain same throughout the program execution. However, the main difference between variable and constant in C is that we can’t change the value of constant in between the program, but...

Learn C - understanding c programming 47

Learn C with help of an example

In this article, we will learn C by going through the below program and understanding each line of C code in detail. 1) /* 2) Program: 3) Addition of two numbers 4) */ 5) //Here it starts 6) #include<stdio.h> 7) #include<conio.h> 8) Void main() 9) { 10) int a, b, c; 11) /*Assign the values to the variable a and b */ 12) a = 5; 13) b = 4; 14) /*Perform addition of a and b */ 15) c = a + b; 16) printf(“\nAddition of a and b is %d”, c); 17) } Let us learn C by...

sizeof operator in C 4

sizeof operator in C

sizeof operator in C is an unary operator which can be used to find the size of the data-type or expression or a variable. It returns the size of the memory allocated (in Bytes) by the compiler. Lets say, we want to find the size of the memory allocated to the data-type int. We can find it by using sizeof operator as shown in the below code: #include<stdio.h> #include<conio.h> void main() { clrscr(); int sizeOfInt; sizeOfInt = sizeof(int); printf(“%d Bytes”, sizeOfInt); getch(); } Output: 2 Bytes As you can see, the above code calculated the size of int data type...

Scope of Local and Global Variables in C Programming 1

Scope of Local and Global Variables in C Programming

The scope of variables refers to that portion of the program where the variables can be accessed. They are accessible in some portion of the program and in the other they are not accessible. Scope of a variable defines the portion of the program in which the set of variables can be referenced and manipulated. When a variable is required in a program, it can be declared as: Local variable Global variable Local Variables in C Programming Language The variables that are declared inside a function are called as local variables The scope is only within the function in which...

The C Preprocessor Directives 15

The C Preprocessor Directives

The job of the C Preprocessor is to process the source code before it is passed to the compiler. The preprocessor command is also known as directive. The C Program is often called as source code. Before the program is compiled, the source code goes through one process called preprocessor. The preprocessor gets the source code (pr.C file) as input and creates expanded source code (pr.I file). This expanded source code is then passed to the compiler for compilation. Following are the preprocessor directives: Macro expansion File inclusion Conditional Compilation Miscellaneous directives Lets discuss these preprocessor directive one by one....