Computer Science, asked by Ronald11, 1 year ago

WRITE a program to print the multiplication and division of two numbers

Answers

Answered by anuj
0
Heya friend,


your soln:


import java.io.*;
class MULDIV
{
    public static void main()throws IOException
         {
             DataInputStream ak = new DataInputStream(System.in);
             System.out.println("Enter two numbers");
              int a =Integer.parseInt(ak.readLine());
               int  b =Integer.parseInt(ak.readLine());
           int multi = a*b;
           int divi=a/b;
             System.out.println("MULTIPLICATION"+multi);
           System.out.println("DIVISION"+divi);


       }
}



HOPE IT HELPS!!!!!!!!!!!!
Answered by Anonymous
27
ANSWER

.........


THE PROGRAM IS GIVEN BELOW 

#include <stdio.h>


int main()
         { int first, second, add, subtract, multiply; float divide;


         printf("Enter two integers\n"); scanf("%d%d", &first, &second);

           add = first + second; subtract = first - second; multiply = first

* second; divide = first / (float)second; //typecasting print


f("Sum = %d\n",add); printf("Difference = %d\n",subtract);

     printf("Multiplication = %d\n",multiply); printf("Division = %.2f\n",divide); return 0; }





==========================================


When we divide two integers in C language we get integer result for example 5/2 evaluates to 2. As a general rule integer/integer =                                                                                                                 integer and float/integer =                                                               float or integer/float = float. So we convert denominator to float in our program, you may also write float in numerator. This is known as explicit conversion typecasting.


Ronald11: ????????
Ronald11: sorry but I needed in java
Similar questions