- 3
Write a C++ while clause that stops the loop when the value in the variable called even variable is not an even number
2 Antworten
+ 1
What is your attempt?
0
It is simple to do. You just have to divide by two using the rest of the division:
void msg_is_even( int number ){
printf( "the number: '%d' ",number );
if ( !number%2 ){// number==0
printf( " Is even" );
}else{
printf( " Not is even" );
}
}
number=2;//2 is even.
msg_is_even( number );
number++;//3 not is even.
msg_is_even( number );