Declair a variable
Feb 8, 2015 at 8:01pm UTC
Guys, sorry to bother but can anyone explain me how I should declair x variable in this case? I am always having problems with it and I cant find a solution...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include "stdafx.h"
#include <iostream>
void IsEven()
{
using namespace std;
int x, y = 8;
if (x %= y)
cout << "true" << endl;
else
cout << "false" << endl;
}
int main()
{
using namespace std;
cout << "enter a number: " ;
cin >> x;
cout << endl;
IsEven();
system("pause" );
return 0;
}
Feb 8, 2015 at 8:17pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
bool IsEven(int x){
return x%2 == 0;
}
int main(){
int x, foo, the_name_is_irrelevant;
std::cin >> x >> foo >> the_name_is_irrelevant;
std::cout << std::boolalpha;
std::cout << IsEven(x) << '\n' ;
std::cout << IsEven(foo) << '\n' ;
std::cout << IsEven(the_name_is_irrelevant) << '\n' ;
}
Feb 8, 2015 at 8:19pm UTC
ok ty!
Topic archived. No new replies allowed.