int doubles (int d);
int minimum (int m, int n);
int oddEven (int a);

int main ()
{

	int num, i, sum=0, num1, num2;

	for (i=0; i<5; i++)
	{

		cout<<"please enter a number. ";
		cin>>num;
		cout<<endl;
		sum= sum + num;

	}

	cout<<"the numbers added together is "<<sum<<endl;
	cout<<"the sum of the 5 numbers doubled is "<<doubles(sum)<<endl;
	cout<<endl;

	
	int oOrE=oddEven(sum);

	if (oOrE == -1)
		cout<<"the sum is odd"<<endl;
	else
		cout<<"the sum is even"<<endl;

	cout<<"please enter a number. ";
	cin>>num1;
	cout<<endl;

	cout<<"please enter a number. ";
	cin>>num2;
	cout<<endl;

	cout<<"the minimun of the two numbers is "<<minimum(num1, num2)<<endl;


	
return 0;
}



int doubles (int d)
{
	d=d*2;

	return d;

}

int minimum (int m, int n)
{

	int mini;

	if (m<n)
		mini=m;

	else 
	    mini=n;

	return mini;
}

int oddEven (int a)
{
	int oE;

	if (a%2!=0)//odd
		oE= -1;
		
	
	else 
		oE=1;
		
	return oE;


}
*/

Dani AI

Generated

Quick summary and immediate fixes for 's snippet

There are three likely reasons the program won't compile or behaves unexpectedly. First, standard I/O names need the proper header and either std:: qualification or a using-declaration (as suggested). Second, the stray */ at the end of the file will produce a syntax error — remove it. Third, enable compiler diagnostics to see problems clearly: compile with warnings on (for example, g++ -Wall -Wextra -std=c++11) and paste the exact error text when asking for help (as requested).

Suggested small design and safety improvements

  • Prefer clearer names and types: return a boolean for odd/even checks (name it is_even or isOdd) instead of -1/1, and consider using a wider integer type for the running sum if users may enter large values.
  • Use the standard library for common tasks: std::min (from <algorithm>) for the minimum, and std::accumulate or a small loop for summing if you move to containers.
  • Avoid unnecessary endl (use '\n') and validate input immediately after each cin >> to handle non-numeric input gracefully.

Practical snippets and checklist

A compact is_even approach:

bool is_even(int n) { return (n % 2) == 0; }

To recover from bad input:

if (!(cin >> value)) {
  cin.clear();
  cin.ignore(10000, '\n');
  // ask again
}

Checklist: remove stray comment terminator, add standard I/O handling, run with -Wall, validate inputs, and rename the thread to something descriptive (see ). Include exact compiler errors in follow-ups.

Recommended Answers

All 3 Replies

People here are not psychic. Kindly explaing what problem are you having with the code.

add this to the top of your program

#include <iostream>
using namespace std;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.