~riderius/cpp-code

30266c434d0d51204aeab9d6d0044390de2c29ec — RIDERIUS 4 months ago 743315d
Added sqrt program for my shell

Signed-off-by: RIDERIUS <riderius.help@gmail.com>
2 files changed, 18 insertions(+), 0 deletions(-)

M CMakeLists.txt
A sqrt.cpp
M CMakeLists.txt => CMakeLists.txt +1 -0
@@ 18,6 18,7 @@ add_executable(reverse_int reverse_int.cpp)
add_executable(guess_the_number guess_the_number.cpp)
add_executable(codetime codetime.cpp)
add_executable(Mstat math_stat.cpp)
add_executable(sqrt sqrt.cpp)

# Curses progs


A sqrt.cpp => sqrt.cpp +17 -0
@@ 0,0 1,17 @@
#include <ios>
#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;
}