Skip to content

Instantly share code, notes, and snippets.

View mohnoor94's full-sized avatar
๐Ÿ“˜
Always Learning...

Mohammad Noor Abu Khleif mohnoor94

๐Ÿ“˜
Always Learning...
View GitHub Profile
@mohnoor94
mohnoor94 / EvenOddFull.cpp
Last active August 20, 2017 21:12
A full C++ program includes a function that takes as a parameter an integer, and returns the number of odd and even digits.
// www.abukhleif.com
#include <iostream>
using namespace std;
void EvenOdd (int num, int& evens, int& odds) {
evens = odds = 0;
while (num != 0) {
if (num % 2 == 0)
evens++;
else
odds++;
@mohnoor94
mohnoor94 / reverseDigitFull.cpp
Last active August 20, 2017 21:13
Reverse Any Integer C++ Full Program | AbuKhleif
// www.abukhleif.com
#include <iostream>
using namespace std;
int reverseDigit (int num){
bool isNegative = false;
if (num < 0){
isNegative = true;
num = -1 * num;
}
int reversedNumber = 0;
@mohnoor94
mohnoor94 / reverseDigitAny.cpp
Last active August 20, 2017 21:13
Reverse Any Integer C++ Function | AbuKhleif
// www.abukhleif.com
int reverseDigit (int num){
bool isNegative = false;
if (num < 0){
isNegative = true;
num = -1 * num;
}
int reversedNumber = 0;
while (num > 0){
int d = num % 10;
@mohnoor94
mohnoor94 / reverseDigitPositive.cpp
Created August 19, 2017 21:17
Reverse Positive Integer C++ Function | AbuKhleif
int reverseDigit (int num){
int reversedNumber = 0;
while (num > 0){
int d = num % 10;
reversedNumber = reversedNumber * 10 + d;
num /= 10;
}
return reversedNumber;
}