Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Header file



Specifer



" ; " after loop



Comment



Test expression




Swap two numbers



// AHF C PROGRAM SOLVING

//solving here basic type of programming problem


We can implement swaping in two ways.
The first way is below:
#include<stdio.h> #include<math.h> #define pf printf int main() { int x,y,temp; pf("\nEnter two integer number: "); scanf("%d %d",&x,&y); temp=x; x=y; y=temp; pf("\nAfter swap the number is : %d and %d",x,y); return 0; }
The second way is below:
#include<stdio.h> #include<math.h> #define pf printf int main() { int x,y,temp; pf("\nEnter two integer number: "); scanf("%d %d",&x,&y); x=x+y; y=x-y; x=x-y; pf("\nAfter swap the number is : %d and %d",x,y); return 0; }
OUTPUT:

User may also visit:



  1. Calculate result in CGPA

© 2018 - All rights reserved