"C' Examples C

Program to swap the two variables values within and without third variables.

Problem Analysis:

The problem is to swap the variables values with and without using third variables having parameters a,b,c,d,e .

The output is to print the variables by swapping.

Input variables              processing variables                        Output variables                           Necessary header file

a(int)                                   c=a                                              a(int)                                                 stdio.h

b(int)                                   a=b                                              b(int)                                                 conio.h

d(int)                                   b=c                                              d(int)

e(int)                                   d=d+e;                                        e(int)






2.Input the variables by the user.

i.e. int a ,b,d,e

3.Swapping the values with and without using the 3rd variables.

such as:    c=a;                 d=d+e;

a=b;                e=d-e;

b=c;                d=d-e;

4.Print the outputs a ,b,d and e ;




fig: flowchart to swap the numbers.



/*program to swap two variables values with and without using third variables*/



int main()


int a,b,c,d,e;

printf(” enter a ,b,d,e:”);


printf(“before swapping:%d%d”,a,b);




printf(“after swapping:%d%d”,a,b);

printf(“before swapping:%d%d”,d,e);




printf(“after swapping:%d%d”,d,e);


return 0;




(Compiling , Debuggings and Testings)

enter a ,b,d,e : 3  4  6 8

before swapping: 3  4

after swapping   : 4  3

before swapping : 6  8

after swapping    : 8  6

We the teams of programming faster managed to provide an effective information about the codes of different programming languages.Hope you will learn and understand the codes fast and easy. It's absolutely free, expanding and precise. Our main target is to help those new starters and aid them as far as possible to pave their future in the area of programming. Hoping support and recommendations!

Related Posts

HTML color code

HTML (Hypertext Markup Language) is a standard markup language that is used for creating and structuring web pages. HTML provides a set of elements and tags that define…

C program to add two numbers and display sum in the screen

CODES:   OUTPUTS: enter values of a and b: 2 3 the sum is 5.00

C program to read a character from user and display it ASCII value

CODES:   CODES: enter a character: B the ASCII value of character B is 66

C program to read three sides of a triangle and calculate the area

CODES:   OUTPUTS: enter three sides of triangle a,b,c:3 4 5 the area of the triangle is :6.00

C program to read height and base of a triangle and find the area of it

CODES: OUTPUTS: enter the height of triangle:5 enter the base of triangle :3.5 the area of the triangle is:8.75

C program to calculate the area and perimeter of rectangle

CODES: OUTPUTS: enter the length and breadth of a rectangle :2.5  1.5 the area of rectangle is :3.750000 the perimeter of rectangle is :8.000000

Leave a Reply

Your email address will not be published. Required fields are marked *