C++ Write a program which accepts a floating-point number as a command-line argu
ID: 3790825 • Letter: C
Question
C++ Write a program which accepts a floating-point number as a command-line argument, then delays for that number of seconds (use the usleep function). In addition, it should show a progress bar indicating the time left (which should update on a single line; use carriage return to re-print it). Your progress bar should update every quarter-second. Call the program sleep.cpp. Verify that the input is correct (it can only be non-negative integer or float). Be sure that when you call the program to distinguish it from the system program sleep MUST BE IN C++ AND NEEDS TO BE THE ACTUAL CODE
Explanation / Answer
/* go.c Takes one input argument from the command line, an integer, and returns 1 if the number is prime, and 0 if it is not. Compile with: gcc -o go go.c primes.c */ #include #include #include "primes.h" int main(int argc, char *argv[]) { if (argc < 2) { printf("error: must provide a single integer value to test "); return 1; } else { int n = atoi(argv[1]); int prime = isPrime(n); printf("isPrime(%d) = %d ", n, prime); return 0; } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.