cmake/Tests/Tutorial/Step1/tutorial.cxx

20 lines
552 B
C++
Raw Normal View History

// A simple program that computes the square root of a number
2016-07-09 11:21:54 +02:00
#include "TutorialConfig.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
2016-07-09 11:21:54 +02:00
int main(int argc, char* argv[])
{
2016-07-09 11:21:54 +02:00
if (argc < 2) {
fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
Tutorial_VERSION_MINOR);
2016-07-09 11:21:54 +02:00
fprintf(stdout, "Usage: %s number\n", argv[0]);
return 1;
2016-07-09 11:21:54 +02:00
}
double inputValue = atof(argv[1]);
double outputValue = sqrt(inputValue);
2016-07-09 11:21:54 +02:00
fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
return 0;
}