C++ please no arrays!
Create a program that will allow the user to enter up to 50 whole values and determine the number of values entered, how many of the values were odd and how many of the values were even. Your code should contain 2 functions, a main function and a function to enter the numbers enter and count the values. Your main function should be a driver program that will call another function to count the total number of values entered, the number of even numbers entered, and the number of odd numbers entered, then output the values sent back to the function call. Use a function (other than main) that will prompt the user to enter up to 50 whole numbers values and count how many even and odd numbers were entered (0 should be considered an even number) utilizing a loop. The loop should continue as long as the user wants to enter another value and the number of values entered is less than 50. The function should send back to the function call how many values were entered and how many odd and even numbers were entered. Use a minimum number or arithmetic operators inside the loop, do not use multiplication or subtraction in the loop.
Please keep program as simple/basic as possible
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
using namespace std;
// Function Declarations
void getNos(int &cnt,int &cntEven,int &cntOdd);
int main() {
//Declaring variables
int cnt,cntEven,cntOdd;
//calling the function
getNos(cnt,cntEven,cntOdd);
cout<<"No of Values entered
:"<<cnt<<endl;
cout<<"No of Even Numbers
:"<<cntEven<<endl;
cout<<"No of Odd Numbers
:"<<cntOdd<<endl;
return 0;
}
/* This function will read and the numbers
* and count no of even nos and odd numbers entered
*/
void getNos(int &cnt,int &cntEven,int &cntOdd)
{
int num;
const int SENTINEL=-999;
while(true)
{
cout<<"Enter a number (-999
to exit) :";
cin>>num;
if(cnt==50 || num==-999)
{
break;
}
else
{
cnt++;
if(num==0 ||
num%2==0)
{
cntEven++;
}
else
{
cntOdd++;
}
}
}
}
_____________________________
Output:
_______________Could you plz rate me well.Thank
You
C++ please no arrays! Create a program that will allow the user to enter up to...
Problem: Create a program that contains two functions: main and a void function to read data from a file and process it. Your main function should prompt the user to enter the name of the file (Lab7.txt), store this name, and then call the function sending the name of the file to the function. After the function has completed, the main function should output the total number of values in the file, how many of the values were odd, how...
Create a Java program which asks the user how many names they want to enter. The program should then instantiate an array that will hold this many names. The main method should call a method, getNames() to allow the user to enter the names. A for loop should be used in this method. Once the names are entered, the main method should call another method displayNames() which will use a while loop to display the names entered.
Write a c++ complete program to meet the specifications. The program should prompt the user for a positive integer. The program should print a message whether the integer is even or odd. The looping should end when the user enters a negative number. The negative number will not be tested for even or odd. The program will print out a message of how many numbers were entered (not counting the negative number) and how many even and odd numbers were...
Write a java program that keeps asking the user to enter a number until the user quits and prints how many even and how many odd numbers entered by the user. The loop terminates if the user enters -1 (it indicates that there will be no more number entering by the user). In other words, as long as the user doesn’t enter -1, the loop will be executed. Please add comments to the program to understand/ explain the code.
Thank you!
/*Lab 8 : Practicing functions and arrays
Purpose:
*/
#include<iostream>
#include<fstream>
using namespace std;
int read_function(int array[], int, int);
int main()
{
int array[300], numba;
read_function(array[300]);
cout << "Enter a whole number between 2-20: " <<
endl;
cin >> numba;
read_function(numba);
return 0;
}
int read_funtion (int arr[300], int num, int Values)
{
int sum=0;
ifstream array_file;
array_file.open("Lab8.dat");
for(int i=0; i < 300; i++)
{
array_file >> arr[i];
cout << arr[i];
sum += i;
}
cout << sum;...
C++
Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...
Name your c++ file cpp. BScore_LastNameFirstName.cpp Write a program that contains a function call Input. The Input function should accept 2 decimal test scores that was entered from the user and stores them in an array. Don’t store any number less than 0. Return the array to main. Inside main, the program should pass the array and the total number of scores to countBGrade function. The countBGrade function should count how many B scores (80 to 89) were entered by...
c++ please
(1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another 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).
C++
Problem #1 Write a program that prompts user to enter an integer up to 1000 and displays back a message about the number of digits in this number and if number is odd or even. For example, if user enters 93 message back should be "93 has 2 digits and is odd".