Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Program Discussion :: Basics

Home > Programs > Basics

1 / 248

Write a program to find the difference of two numbers must always be positive.

Answer:

#include 
#include
using namespace std;
int main() {
    int a[10], n;
    int largest1, largest2, i;

    coutn;
     couta[i];
    }
    largest1 = a[0];
    for (i = 0; i < n; i++) {
        if (a[i] > largest1) {
            largest1 = a[i];
        }
    }
    largest2 = a[0];
    for (i = 1; i < n; i++) {
        if (a[i] > largest2 && a[i] < largest1)
            largest2 = a[i];
    }
     cout

Asked In :: Tech Mahindra

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here: