ALGO
Algorithm
Input An integer. Output Print number is even or odd. Complexity O(1) Even-odd(n) 1 If (n%2=0) then 2 Print number is even 3 else 4 Print number is odd
PROG
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter an integer: ";
cin >> n;
if ( n%2 == 0) {
cout << n << " is even.";
}
else {
cout << n << " is odd.";
}
return 0;
}
No comments:
Post a Comment