pretty new to coding and have an assignment that i need guiding with.
Here's the prompt.
I can get code that works but is not using functions and I'm struggling with how to integrate them into this. please help
Overview: Write a program that can determine whether a user input is a binary number or not. (1, 2, 3, 8, 13)
Write a program that accomplishes all of the following:
- Greets the user and informs them that the program will determine whether an input from the user is a valid binary number or not (e.g., consisting of only 0’s and/or 1’s).
- Accept an integer input from the user. Assume that the user provides a valid numeric input that will fit in the standard integer type. However, check to make sure the input was a positive number - for our purposes, any negative integer input is not a binary number.
- Use a loop to check all of the digits of the given input to determine that they are either 0 or 1 (hint: you may want to use the modulus and division operators to process the digits one-by-one).
- If all digits were either 0 or 1, print a message to the user stating that the input was a valid binary number. Otherwise, print a message stating that the input was not a valid binary number.
- Test your program thoroughly. Make sure to at least the following inputs and verify the results:
- 0: binary
- 1: binary
- 01: binary
- 21001: not binary
- -1011: not binary
- 123: not binary
- 10101: binary
- Use at least two functions to solve the problem.
Here's the code I have that is not using functions
project 2
NEEDS TO USE 2 FUNCTIONS, CURRENTLY DOES NOT
Code:#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main() { printf("Hello, this program determines whether your input is or is not binary") int n; printf("Enter a number: "); scanf("%d", &n); if (n < 0) { printf("%d: not binary\n", n); } else { int isBinary = 1; int mod, t = n; while (t > 0) { mod = t % 10; if (mod != 0 && mod != 1) { isBinary = 0; break; } t = t / 10; } if (isBinary) { printf("%d: binary\n", n); } else { printf("%d: not binary\n", n); } } return 0; }