Computer Science, asked by 201718eee41, 1 year ago

Write a program to read a number of any length. Perform addition and subtraction on the largest and smallest digits.

Answers

Answered by Rumi123456789
3
BLUEJ PROGRAM :-
import java.util.Scanner;
public class Add_Subtract
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int a,b,c,d,e;
System.out.println("Enter two numbers");
a=in.nextInt();
b=in.nextInt();
if (a>b || b>a)
c=(a+b);
System.out.println("The sum of those two numbers are : "+c);
else if(a>b)
d=(a-b);
System.out.println("The difference of the largest and smallest numbers are : "+d);
else
e=(b-a);
System.out.println("The difference of the largest and smallest numbers are : "+e);
}
}

201718eee41: I need c program answer not java answer anyway thank u for ur response
Answered by bandameedipravalika0
0

Answer:

Explanation:

C++:

                 Many people believe that C++, an object-oriented programming (OOP) language, is the finest language for developing complex applications.The C language is a superset of C++. Java, a closely comparable programming language, is based on C++ and is tailored for the distribution of programmed objects across a network like the Internet.Java offers a few advantages over C++ in addition to being a little simpler and simpler to understand.

Both languages, however, demand a significant amount of study.

Program:

using namespace std;

// Function to the largest and smallest digit of a number

void Digits(int n)

{

   int largest = 0;

   int smallest = 9;

   while (n) {

       int r = n % 10;

       // Find the largest digit

       largest = max(r, largest);

       // Find the smallest digit

       smallest = min(r, smallest);

       n = n / 10;

   }

   cout << largest << " " << smallest;

}

// Driver code

int main()

{

   int n = 2346;

   // Function call

   Digits(n);

   return 0;

}

Output:

   6 2

Explanation:

                   The above program is to read a number pf any length and to perform addition ,subtraction on the largest and smallest digits. First we declare the large number and smallest number and then using the call function they return the value.

#SPJ2

Similar questions