212k views
3 votes
Help with c program

hw08c.c

print the numbers from one to 20 along with whether each number is even or odd and prime or compositr.

1. Use a function bool isEven(int x ) which returns true if a number is even and false otherwise.
2. Use a function bool isPrime(int x ) which returns true if a number is prime and false otherwise.
1. Determine if a number is prime using a loop.
3. Write a main function that loops through the numbers 1 to 20 and for each number print:
1. >\t< even or odd >\t< prime or composite > \\

1 Answer

3 votes

Final answer:

To solve this problem, you need to write two functions: isEven() and isPrime(). In the main function, you can use a loop to iterate through the numbers 1 to 20 and call the isEven() and isPrime() functions.

Step-by-step explanation:

To solve this problem, you need to write two functions: isEven() and isPrime(). The isEven() function takes an integer as input and returns true if the number is even and false otherwise. The isPrime() function determines if a number is prime or composite using a loop and returns true if the number is prime and false otherwise.

In the main function, you can use a loop to iterate through the numbers 1 to 20. For each number, you can call the isEven() and isPrime() functions to determine if it is even or odd and prime or composite. Finally, you can print the number along with the corresponding information.

User Sayan Malakshinov
by
7.8k points