Category: Learn C Online

Pointers in C 38

Pointers in C

Pointers in C is one of the excellent feature introduced in C. It makes the programming very interesting. A pointer in C is a variable that represents the location (rather than the value) of a data item. Talking like a layman, C pointers points to an object or something. Let us understand C pointers in detail. Before learning the basics of pointers, let us understand how the variable is stored in the memory. When we declare a variable and assign a value to the variable, we are actually naming the memory location at which the value will be stored. The...

Function declaration and Prototype in C Programming Language 19

Function declaration and Prototype in C Programming Language

By default, any C function returns an int value. If we want that the function should return a value other than int then we need to explicitly mention it in the function definition. Let us understand this using an example. Example 1: float fnGetAverage(int, int); //function prototype void main() { int x,y; float z; printf(“\nEnter the values for x and y\n”); scanf(“%d %d”, &x, &y); z = fnGetAverage(x,y); //function call printf(“\nThe average is %f”, z); } float fnGetAverage(int a, int b) { //function definition float c; c = (a+b)/2; //calculating average return c; //returning the value } Output: Enter the...

Functions in C 27

Functions in C

Let us understand the concept of functions in C language with the help of day to day scenario. Let us suppose that we want to write a program that will perform all the operations required for banking. So we will have to write a program that will have following steps: Accept account number and other personal details of the customer as a input Accept the details of the transactions to be performed If the customer wants to withdraw the money, then program should fetch the balance amount and perform eligibility check After performing eligibility check, the money is deducted from...

for Loop in C programming language 42

for Loop in C programming language

In this article, I will explain usage of for loop in C. You will understand the syntax of for loop and learn how for loop works in C language. Let’s get started. In while and do-while statements, we need to write logic to repeatedly execute a block of statement by initializing a counter and incrementing it after each set of steps. This sometime looks tedious and decreases the readability of the program. The readability of the C program can be improved by using C for loop. Using for loop in C, we can merge all the three parts i.e. assignment,...

do while loop in C programming language 24

do while loop in C programming language

Let us understand do while loop in C with help of an example. syntax: do { /*block of statement*/ }while(condition); Explanation of do while loop in C: Here, while and do are the keywords in C language which is know to the compiler. Condition can be any expression. This is very similar to while loop in C. Here, the block of statement enclosed in the opening and closing braces after the keyword do is executed at least once. After the execution of the block of statement for the first time, the condition in the while is executed. If the condition...

Loops in C Programming 10

Loops in C Programming

Loops in C are used to change the sequence or flow of the program. The basic behavior of the program is that it starts it from the beginning of the program, executes the particular statement only once and proceeds to the next statement. This behavior is continued till the end of the program is reached. But sometimes we need to execute a particular statement more than once. At this point Loops in C plays an important role. Following are the types of Loops in C language we can use in the program: while loop do-while loop for loop statement

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet