Have a Read!

Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!

Wednesday, January 26, 2011

C PROGRAM FOR SWAPPING TWO NUMBERS

#include<stdio.h>
int main()
{
int no1;
int no2;
printf("Enter first no\n");
scanf("%d",&no1);            
printf("enter second no\n");
scanf("%d",&no2);            
printf("\nBefore swapping\n");
printf("no1=%d no2=%d\n",no1 ,no2);
no1=no1+no2;                  
no2=no1-no2;
no1=no1-no2;
printf("\nAfter swapping\n");
printf("no1=%d no2=%d\n",no1,no2);
return 0;
}

No comments:

Post a Comment

Related Posts with Thumbnails