pointer example program in C

pointer c program example

pointer example program in C What would be the output of following pointer program written in c   main( ) { int a = 10, b = 20 ; swapr ( &a, &b ) ; printf ( “\na = %d b = %d”, a, b ) ; } swapr( int *x, int *y ) { … Read more

Introduction to Pointers in C

understanding c pointers

Introduction to Pointers in C Pointer Notation Consider the declaration, int i = 3 ; This declaration tells the C compiler to: Reserve space in memory to hold the integer value. Associate the name i with this memory location. Store the value 3 at this location. We may represent i’s location in memory by the … Read more

if else statement in c

C Programming Tutorial

The if statement by itself will execute a single statement, or a group of statements, when the expression following if evaluates to true. It does nothing when the expression evaluates to false. Can we execute one group of statements if the expression evaluates to true and another group of statements if the expression evaluates to … Read more

write a C program to calculate the sum of its digits

C Programming Tutorial

Problem Statement: If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. Answer: /* Sum of digits of a 5 digit number*/ #include<stdio.h> #include<conio.h> main() { int num,a,n; int sum=0; /* this has been initialised to zero otherwise it will contain a garbage value */ clrscr(); … Read more

Write basic C program to calculate gross salary

C Programming Tutorial

Write a C Program for the following :- Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary. Answer:  /* To Calculate the gross salary of Ramesh */ #include<stdio.h> #include<conio.h> main() { … Read more

Nesting of Loops in C

nesting of loop

The way if statements can be nested, similarly whiles and for can also be nested. To understand how nested loops work, look at the program given below: /* Example of nested loops */ main( ) { int r, c, sum ; for ( r = 1 ; r <= 3 ; r++ ) /* outer loop … Read more

The For loop in C

C Programming Tutorial

For loop is probably the most popular looping instruction. The for allows us to specify three things about a loop in a single line: Setting a loop counter to an initial value. Testing the loop counter to determine whether its value has reached the number of repetitions desired. Increasing the value of loop counter each time the … Read more

The While loop in C

C Programming Tutorial

It is often the case in programming that you want to do something a fixed number of times. Perhaps you want to calculate gross salaries of ten different persons, or you want to convert temperatures from centigrade to Fahrenheit for 15 different cities. Let us look at a example which uses a while loop. The … Read more

Hierarchy of Operators Revisited in C

C Programming Tutorial

Since we have now added the logical operators to the list of operators we know, it is time to review these operators and their priorities. The higher the position of an operator is in the table, higher is its priority. The following figure summarizes the working of all the three logical operators.

! the logical operator not in C

C Programming Tutorial

In this article we will learn about the NOT operator, written as !. This operator reverses the result of the expression it operates on. For example, if the expression evaluates to a non-zero value, then applying ! operator to it results into a 0. Vice versa, if the expression evaluates to zero then on applying … Read more