From e8a6c4b2cda5296cc4874e893450428aca72753b Mon Sep 17 00:00:00 2001 From: g5-chappell <gareth2.chappell@live.uwe.ac.uk> Date: Fri, 5 Nov 2021 00:12:18 +0000 Subject: [PATCH] Upload New File --- main.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..69151c3 --- /dev/null +++ b/main.cpp @@ -0,0 +1,84 @@ +#include <iostream> +#include <stdlib.h> +#include <stdio.h> + +using namespace std; + +int main() +{ + // Task 1 - Print greeting + printf("Hello World!\n\n"); + + // Task 2 - Print 10 times + int i = 0; + + for (i = 0; i < 11; i++) + { + + printf("Message loop!\n"); + + } + printf("\n\n"); + + // Task 3 - Name input + printf("INPUT NAME:\n"); + + string name; + + cin >> name; + + cout << "Hello " << name << "\n\n" << endl; + + // Task 4 - User input number of repeats + + int repeats = 0; + + while (repeats = 0); + { + printf("INPUT LOOP COUNT:\n"); + cin >> repeats; + + if (repeats > 0) + { + printf("INPUT SUCCESS! LOOP COUNT IS %d\n", repeats); + } + else + { + printf("SYNTAX ERROR! LOOP COUNT MUST BE INTEGER GREATER THAN 0!\n"); + } + } + + printf("\n\n"); + + // Task 5 - Fizz Buzz Test + + int x = 0; + + for (x = 0; x < 31; i++) + { + if (x % 3 == 0 && x % 5 == 0) + { + printf("FIZZ AND BUZZ! %d\n", x); + x++; + } + else if (x % 3 == 0) + { + printf("FIZZ! %d\n", x); + x++; + } + else if (x % 5 == 0) + { + printf("BUZZ! %d\n", x); + x++; + } + else + { + printf("%d\n", x); + x++; + } + } + + printf("WORKSHEET COMPLETE!\n\n"); + + return 0; +} -- GitLab