~riderius/cpp-code

cpp-code/sqrt.cpp -rw-r--r-- 332 bytes
380d65aariderius digits_analysis.cpp: argv[1] can replace n 11 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <cmath>
#include <cstdlib>

int main(int argc, char* argv[]) {
    long long num;
    if(argc < 2) {
        std::cout << "Enter a number: ";
        std::cin >> num; 
    }
    else {
        num = std::atoll(argv[1]);
    }
    std::cout << std::fixed << std::sqrt(num) << std::endl; 
    return 0;
}