Q: Two number are input through the keyboard into two two locations C and D. write a program to interchange the contents of C and D.

#include <stdio.h>

int main()
{
    float C,D;    /*C and D are two variables*/
   
    printf("enter value of C and D respectivly:");
    scanf("%f%f",&C,&D);
   
    /*steps to interchange value of two variables*/
    C=C+D;
    D=C-D;
    C=C-D;
   
    printf("value of C is %f\nvalue of D is %f\n",C,D);
   
    return 0;
}

-----------------------------------------
output :
enter value of C and D respectivly:5
4
value of C is 4.000000
value of D is 5.000000
 

Comments

Popular posts from this blog

Q: The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate area & perimeter of the rectangle and area & circumference of the circle.

Q: If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)