Skip to content
Snippets Groups Projects
Commit e8a6c4b2 authored by g5-chappell's avatar g5-chappell
Browse files

Upload New File

parent 0e05efb2
Branches
No related tags found
No related merge requests found
main.cpp 0 → 100644
#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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment