Question 2.19

mail@pastecode.io avatar
unknown
c_cpp
a year ago
945 B
2
Indexable
// Online C++ compiler to run C++ program online
#include <iostream>

int main() {
    // Write C++ code here
    int numbers [3];
    std::cout << "Input three different integers: ";
    for(int i; i<3; i++){
        std::cin >> numbers[i];
    }

    std::cout<<"\n";
    int sum = numbers[0] + numbers[1];
    std::cout << "Sum is : "<< sum <<"\n";
    
    double average = static_cast<double>(numbers[0] + numbers[1] + numbers[2])/3;
    std::cout<< "Average is " << average<<"\n";
    
    int product = numbers[0]  *  numbers[1] * numbers[2];
    std::cout << "Product is : "<< product <<"\n";
    int min = numbers[0];
     int max = numbers[0];
    for(int i = 0; i<3; i++){
        if(numbers[i] > max){
            max = numbers[i];
        }
        if(numbers[i] < min){
            min = numbers[i];
        }
    }
    
    std::cout<< "Smallest is "<< min<<"\n";
    std::cout<<"Largest is "<<max<<"\n";
    
    
    return 0;
}