Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to read two positive numbers and interchange it's values using *(mul) and /(div) operators and without using any extra variable

Posted By: Ava Campbell     Category: C Programming     Views: 4848

WRITE A PROGRAM TO READ TWO POSITIVE NUMBERS, SAY N1 AND N2 ARE INTERCHANGE WITHOUT USING ANY EXTRA VARIABLES. N1=10, N2=20 THEN OUTPUT IS N1=20, N2=10 BY THE MULTIPLICATION (*) AND DIVISION (/).

Code for Program to read two positive numbers and interchange it's values using *(mul) and /(div) operators and without using any extra variable in C Programming

#include<stdio.h>
#include<conio.h>
void main()
{
    int a,b;
    clrscr();
    printf("\n Enter The Value of A: ");
    scanf("%d",&a);
    printf("\n Enter The Value of B: ");
    scanf("%d",&b);

        a = a*b;
        b = a/b;
        a = a/b;
        clrscr();
        printf("\n\t\t According to *,/ sign : \n");
        printf("\n\t\t Value of A %d ",a);
        printf("\n\t\t Value of B %d ",b);

    getch();
}



****************************** INPUT *********************************

 Enter The Value of A: 45

 Enter The Value of B: 25




****************************** OUTPUT *********************************



                 According to *,/ sign :

                 Value of A 25
                 Value of B 45
  
Share: 



Ava Campbell
Ava Campbell author of Program to read two positive numbers and interchange it's values using *(mul) and /(div) operators and without using any extra variable is from Toronto, Canada.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!