Wednesday, 2024-04-24, 3:25 AM
ebooks Programming Computer Science
Welcome Guest | RSS
Site menu
Section categories
My articles [23]
Main » Articles » My articles

Without using any conditional statement check whether a number is even or not?
#include <iostream>
#include <string>
#include <bitset>

int main() {

std::string const type[] = {"even", "odd"};
int n;
std::cout << "Enter an integer." << std::endl;
std::cin >> n;
std::cout << type[(std::bitset<1>(std::abs(n))[0])] << std::endl;
}




Category: My articles | Added by: Sumrat (2012-11-04)
Views: 10059 | Comments: 4 | Rating: 0.0/0
Total comments: 0
Name *:
Email *:
Code *:
Our poll
Rate my site
Total of answers: 164
Statistics

Total online: 1
Guests: 1
Users: 0
Login form