#include <stdio.h> int evenOdd(int n){ return n%2==0; } int main(){ int n; printf("Enter number: "); scanf("%d",&n); if(evenOdd(n)){ printf("%d is even\n",n); } else{ printf("%d is odd\n",n); } return 0; }
Write a function prototype for a function that will accept a single integer. Create a function...
Write a C++ program that asks the user to enter a single number from 1 to 50 and a choice of "even" or "odd". Using a recursive function, output the sum of all the even or odd integers from 1 up to (and including) that number. Your program does not need to loop and accept more input (only one input of the number then even/odd).
Write the function prototype and the definition of a function call "oddoreven" that determine if an integer value is ODD or EVEN. The function will return a string containing that message. Use only ONE function! As an example if an integer value of 20 was passed to that function then the function will return "20 is an Even Number." if an integer value of 35 was passed to that function then the function will return "35 is an Odd Number."
use C++ please 1. Vowels and Consonants Write a program that asks the user to input three different integers. Write a function called numberStyle for this program that will accept each integer (one at a time) and return the following . If the integer is even, return 1 . If the integer is odd, return -1 . If the integer is zero, return O In main, after calling the function output the appropriate message describing the integers ing the function...
1. String Length Write a function that returns an integer and accepts a pointer to a C-string as an argument. The function should count the number of characters in the string and return that number. Demonstrate the function in a simple program that asks the user to input a string, passes it to the function, and then displays the function’s return value. c++
Exercise 9.2 Write a Python program that collects from the user a single integer. Have the program print “EVEN” if the integer is divisible by 2, and “ODD” if the integer is not divisible by two. [Use the % operator to compute the two’s modulus (remainder of division by two)] Exercise 9.3 Write a Python program that collects from the user two integers. Have the program print “Yes” if the two integers are BOTH greater than 10. Do nothing if...
use C++ Project 6 1. Using vectors or arrays, write a function named word_rev() that reverse any given word. 2. Write a program that will: Ask the user to enter a word. Save the entry as word_entered. Call word_rev on the entry Display the reversed entry (word_entered) 3. Write a function named prime() that determine whether or not a given number n (greater than one) is prime. The algorithm: If n is even then n is not a prime number...
array function • Create a function called show2D. • This function should accept a two-dimensional array as parameter and display its contents that are odd numbers on the screen. • This function should work with any of the following arrays of different sizes: int hours[3][9]; int stamps[7][9]; int cities[15][9]; • Write a demo program to show how to use the function show2D. this is c++ program Task 2: Array functions • Create a function called show2D. • This function should...
A factor of an integer N is an integer that divides N evenly. Note that 1 and N are always factors of N. For this task, You will need to write a MIPS program that accepts a positive integer from the standard input, counts and reports how many factors of this integer are even and how many are odd. See the sample run below for required format. Sample runs (user input in blue): Please enter a positive int: 20 User...
(C programming) (Function arguments) Design a function prototype that can accept any type of argument and return an integer.
C++ [10pts] Write a function that takes as a parameter an integer (as a long value) and returns the number of odd, even, and zero digits. Also write a program to test your function.