SO I am completely new to programming and haven't written a successful code yet, but I was thrown into a programming class with little to no knowledge. I have been learning some of the rules but I am still really lost. For this program there are 4 rules I have to follow.
1. If the number is evenly divisible by 5, and does not contain a 6, output "bizz" once (not the number); for example 20, 280, 555.
2. If the number has a 6 anywhere in it, and is not evenly divisible by 5, output "buzz" once (not the number); for example 26,61, 262
3. If the number is evenly divisible by 5, and also contains a 6, output "bozz" once (not the number); for example 65, 620, 165
4. If none of these conditions is true, just output the number.
Example of what it should look like ====
Number: 34
Output: 34
Press any key to continue...
Number: 280
Output: bizz
Number: 265
Output: bozz
This program only needs to work for numbers input that are from 1-999. Again I am completely lost on this stuff so any help is greatly appreciated. Just keep in mind I have 0 knowledge on what I am doing haha.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void main()
{
int number, bizz, buzz, bozz;
int hund = number / 100;
int tens = number / 10 % 10;
int ones = number % 10;
printf("Enter a number:\n");
scanf("%d %d %d %d", number, bizz, buzz, bozz);
(hund != 6) || (tens != 6) || (ones != 6);
number % 5 == 0;
printf("bizz is %d", bizz);
(hund == 6) || (tens == 6) || (ones == 6);
number % 5 != 0;
printf("buzz is %d", buzz);
(hund == 6) || (tens == 6) || (ones == 6);
number % 5 == 0;
printf("bozz is %d", bozz);
(hund != 6) || (tens != 6) || (ones != 6);
number % 5 != 0;
printf("number is %d", number);
}
|