Skip to main content

Swap two numbers.( using temporary variable).

PROCEDURE:-

      1.input values for a and b
      2. store value of a in t
      3. store value of b in a
      4. store value of t in b
      5.print value of a and b after swapping



CODE:-

#include<stdio.h>
void main()
{
  int a,b,t;
  printf(“enter value for a,b”);
  scanf(“%d %d”,&a,&b);
  printf(“before swapping  a=%d   b=%d”,a,b);
  t=a;
  a=b;
  b=t;
  printf(“after swapping  a=%d    b=%d”,a,b);
}



Input:- enter value for a,b
                a=5,   b=6
Output:- after swapping  a=6   b=5

Comments

Popular posts from this blog

Find Value of S=ut+1/2*a*t**2.

PROCEDURE:-        1.enter values for u,a,t to find distance        2.find distance with the formulae ut+1/2at 2        3.print the above result CODE:- #include<stdio.h> #include<conio.h> void main() {   float u,t,a,S;   clrscr();   printf(“enter values u,t,a”);   scanf(“%f %f %f”, &u,&t,&a);   S=(u*t)+(0.5*a*t*t);   printf(“\n  S = %f”, S); } Input:- enter values u,t,a               U=10,t=4,a=4.9 Output:- S =79.200