Question

What does this error message mean? "expected primary expression before int" Also, how do i get...

What does this error message mean? "expected primary expression before int"

Also, how do i get the program to repeat the numbers that were entered by the user back to me?

this is my code below:

// This program accepts a series of positive numbers
// This code was last modified on 2/16/2020

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;


void welcome();
int entrySubmission(int numbers);
void acceptsNumbers(int);
void goodbye();

int main()
{

welcome();

entrySubmission(int numbers);

acceptsNumbers(int);

goodbye();


return 0;

}

void welcome()
{
   cout << "Welcome to the Positive Number Program!" << endl;
   cout << "" << endl;
   cout << "In this program you will enter a series of positive numbers \n";
   cout << "When you have completed entering your numbers, enter a \n";
   cout << "to end the end the entry portion of the program" << endl;
   cout << "" << endl;
}

int entrySubmission(int numbers) //need loop to enter numbers until zero
{
   cout << "Please enter a series of positive numbers. \n";
   cout << "Please enter a zero when you have completed your entries." << endl;
   cin >> numbers;

   while (numbers < 0)
   {
       cout << "Negative numbers are not allowed. Please enter a positive number." << endl;
       cin >> numbers;
   }

   while (numbers > 0)
{
cout << "Please enter your next positive number." << endl;
cin >> numbers;
}

if (numbers == 0)
{
cout << "The numbers you entered are" << numbers << endl;
       return;
}
}


void acceptsNumbers(int)
{
if (numbers <= 10)
{
cout << "10 or fewer positive numbers were entered" << endl;

    else
cout << "More than 10 positive numbers were entered" << endl;
}
}


void goodbye()
{
   cout << "Thank you for using the Positive Number Program! Goodbye!" << endl;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//header files

#include <iostream>

#include <iomanip>

#include <cmath>

#define N 1024 //for array size

using namespace std;

//Declarations

void welcome();

void entrySubmission(int numbers);

void acceptsNumbers(int);

void goodbye();

//Entry point function

int main()

{

int numbers = 0; //initilise first

//function calls

welcome();

entrySubmission(numbers);

acceptsNumbers(numbers);

goodbye();

return 0;

}

//defination of functions

void welcome()

{

cout << "Welcome to the Positive Number Program!" << endl;

cout << "" << endl;

cout << "In this program you will enter a series of positive numbers \n";

cout << "When you have completed entering your numbers, enter a \n";

cout << "to end the end the entry portion of the program" << endl;

cout << "" << endl;

}

void entrySubmission(int numbers) //need loop to enter numbers until zero

{

int Count_number = 0;

int arr[N];

cout << "Please enter a series of positive numbers. \n";

cout << "Please enter a zero when you have completed your entries." << endl;

cin >> numbers;

Count_number++;

arr[Count_number] = numbers;

while (numbers < 0)

{

cout << "Negative numbers are not allowed. Please enter a positive number." << endl;

cin >> numbers;

Count_number++;

arr[Count_number] = numbers;

}

while (numbers > 0)

{

cout << "Please enter your next positive number." << endl;

cin >> numbers;

Count_number++;

arr[Count_number] = numbers;

}

if ((numbers == 0)||(numbers < 0))

{

cout << "The numbers you entered are " << Count_number << endl;

int i = 0;

for(i=1 ; i<Count_number+1; i++)

{

cout<< " " <<arr[i] << endl;

}

}

}

void acceptsNumbers(int numbers)//defination so we must give paramter with datatype

{

if (numbers <= 10)

{

cout << "10 or fewer positive numbers were entered" << endl;

}

else

{

cout << "More than 10 positive numbers were entered" << endl;

}

}

void goodbye()

{

cout << "Thank you for using the Positive Number Program! Goodbye!" << endl;

}

Add a comment
Know the answer?
Add Answer to:
What does this error message mean? "expected primary expression before int" Also, how do i get...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am having trouble figuring out what should go in the place of "number" to make...

    I am having trouble figuring out what should go in the place of "number" to make the loop stop as soon as they enter the value they put in for the "count" input. I am also having trouble nesting a do while loop into the original while loop (if that is even what I am supposed to do to get the program to keep going if the user wants to enter more numbers???) I have inserted the question below, as...

  • How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0,...

    How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0, b = 1, c; if (n <= 1) return n; for (int i = 2; i <= n; i++) { c = a + b; a = b; b = c; } return b; } int fibonacciRecursive(int n) { if (n <= 1) { return n; } return fibonacciRecursive(n-1) + fibonacciRecursive(n-2); } int main() { int n;...

  • I am working on this switch program everything seems to be ok but the compiler is...

    I am working on this switch program everything seems to be ok but the compiler is giving me an error on the final closing brace and wanted to know where I am making an error #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { int choice; char repeat; double MidTerm = 0; double FinalExam = 0; double Quiz1 = 0; double Quiz2 = 0; double MidTermGrade = 1, FinalExamGrade = 2, Quiz1Grade = 3, Quiz2Grade = 4,...

  • Am I getting this error because i declared 'n' as an int, and then asking it...

    Am I getting this error because i declared 'n' as an int, and then asking it to make it a double? This is the coude: #include "stdafx.h" #include <iostream> #include <fstream> #include <string> #include <algorithm> #include <vector> using namespace std; void sort(double grades[], int size); char calGrade(double); int main() {    int n;    double avg, sum = 0;;    string in_file, out_file;    cout << "Please enter the name of the input file: ";    cin >> in_file;   ...

  • Create a new file (in Dev C++) Modify program above to use a vector instead of...

    Create a new file (in Dev C++) Modify program above to use a vector instead of an array. Header comments must be present Prototypes must be present if functions are used Hello and goodbye messages must be shown Vector(s) must be used for implementation Use comments and good style practices ====================================================================================================== #include <iostream> using namespace std; int main() { cout<<"Welcome! This program will find the minimum and maximum numbers in an array."<<endl; cout<<"You will be asked to enter a number...

  • C++ programming I need at least three test cases for the program and at least one...

    C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...

  • Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout...

    Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;

  • How can I make this compatible with older C++ compilers that DO NOT make use of...

    How can I make this compatible with older C++ compilers that DO NOT make use of stoi and to_string? //Booking system #include <iostream> #include <iomanip> #include <string> using namespace std; string welcome(); void print_seats(string flight[]); void populate_seats(); bool validate_flight(string a); bool validate_seat(string a, int b); bool validate_book(string a); void print_ticket(string passenger[], int i); string flights [5][52]; string passengers [4][250]; int main(){     string seat, flight, book = "y";     int int_flight, p = 0, j = 0;     int seat_number,...

  • #include <iostream> #include <conio.h> #include<limits> using namespace std; int main(){ char oparand, ch = 'Y'; int...

    #include <iostream> #include <conio.h> #include<limits> using namespace std; int main(){ char oparand, ch = 'Y'; int num1, num2, result; while(ch == 'Y'){ cout << "Enter first number: "; cin >> num1; while(1){//for handling invalid inputs if(cin.fail()){ cin.clear();//reseting the buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');//empty the buffer cout<<"You have entered wrong input"<<endl; cout << "Enter first number: "; cin >> num1; } if(!cin.fail()) break; } cout << "Enter second number: "; cin >> num2; while(1){ if(cin.fail()){ cin.clear(); cin.ignore(numeric_limits<streamsize>::max(),'\n'); cout<<"You have entered wrong input"<<endl; cout <<...

  • #include <iostream> using namespace std; const int SIZE = 10; void displayGreaterThan(int[], int); void displaySmallerThan(int[],int); void...

    #include <iostream> using namespace std; const int SIZE = 10; void displayGreaterThan(int[], int); void displaySmallerThan(int[],int); void displayArrayContent(int[]); void displayLargestValue(int[]); void displaySmallestValue(int[]); int main(){    int number;    int numbers[SIZE] = {9,1,90,98,53,22,76,29,37,65}; cout <<"Enter a number: "; cin >> number; cout << endl;    displayGreaterThan(numbers,number); cout << endl; displaySmallerThan(numbers,number); cout << endl; displayArrayContent(numbers); cout << endl; displayLargestValue(numbers); cout << endl; displaySmallestValue(numbers); cout << endl;    return 0;       } void displayGreaterThan(int value[],int num){ cout << " All larger value(s)than" <<...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT