Test program for testing breakpoint conditions.

This commit is contained in:
Ernie Pasveer
2023-11-23 15:04:25 -06:00
parent 6a56e2b19a
commit f3e454003d
5 changed files with 66 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
#include <iostream>
#include <stdlib.h>
int main (int argc, char* argv[]) {
if (argc != 2) {
std::cout << "usage: " << argv[0] << " N" << std::endl;
return 1;
}
int t1 = 0;
int t2 = 1;
int nextTerm = 0;
int n = atoi(argv[1]);
// Check N
if (n < 0) {
std::cout << "Bad value of 'N': " << argv[1] << std::endl;
return 1;
}
// Displays the first two terms which is always 0 and 1
std::cout << "Fibonacci Series: " << t1 << ", " << t2 << ", ";
// Display next terms.
nextTerm = t1 + t2;
while (nextTerm <= n) {
std::cout << nextTerm << ", ";
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}
// Final EOL
std::cout << std::endl;
return 0;
}