Skip to main content

Posts

Showing posts from March, 2018

c program for swap two numbers by two ways

We can write the c program for swap in two  ways: 1. by using only two variable, 2. by using three variable. In first we will discuss our first type program i.e. by using only two variable. in this program only two variables are used to swap two numbers, in order to write a program we need to build a logic and after that the program will run. 1.firstly try to solve this program on your own 2.after this try to understand the problem i.e. to swap two numbers 3.now build a logic between two numbers       a=1,b=2    if i write a=b & b=a this is WRONG  way. why this is wrong? A question comes in mind. This is due to the  reason that when a=b (means the value in b is assigned to a) then the value in a will vanish. Now when we wite b=a(means the value in a is assigned to b) but from the above line we came to know that the value of a is vanished and the the value which is in a is of b. so the proper way of making a relation between swaping of a and b is in the program. The