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 / 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;
}
@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 / 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 / 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 / EvenOddFunction.cpp
Last active August 20, 2017 21:12
A C++ function that takes as a parameter an integer, and returns the number of odd and even digits.
// www.abukhleif.com
void EvenOdd (int num, int& evens, int& odds) {
evens = odds = 0;
while (num != 0) {
if (num % 2 == 0)
evens++;
else
odds++;
num /= 10;
}
@mohnoor94
mohnoor94 / ArrayStackJava.java
Created August 19, 2017 22:15
Simple Java Implementation of Stack
// www.abukhleif.com
class ArrayStack {
private final int[] stack;
private final int size;
private int top;
public ArrayStack(int size) {
this.size = size;
stack = new int[size];
}
@mohnoor94
mohnoor94 / ArrayQueueJava.java
Created August 19, 2017 22:17
Simple Java Implementation of Queue
// www.abukhleif.com
class ArrayQueue {
private final int[] queue;
private int first = 0;
private int last = 0;
int size = 0;
public ArrayQueue(int size) {
queue = new int[size];
}
@mohnoor94
mohnoor94 / isVowelFunction1.cpp
Last active August 20, 2017 21:04
A function isVowel that returns the value true if a given character is a vowel and otherwise returns false
// www.abukhleif.com
bool isVowel (char x) {
char y = toupper(x);
return (y=='A' || y=='E' || y=='I'|| y=='O'|| y=='U');
}
@mohnoor94
mohnoor94 / isVowelFunction2.cpp
Last active August 20, 2017 21:07
A function isVowel that returns the value true if a given character is a vowel and otherwise returns false
// www.abukhleif.com
bool isVowel (char x) {
return (x == 'A' || x == 'a' ||
x == 'E' || x == 'e' ||
x == 'I' || x == 'i' ||
x == 'O' || x == 'o' ||
x == 'U' || x == 'u');
}
@mohnoor94
mohnoor94 / isVowelFull.cpp
Created August 20, 2017 21:03
A full C++ program that contains a function isVowel returns the value true if a given character is a vowel and otherwise returns false
// www.abukhleif.com
#include <iostream>
using namespace std;
bool isVowel (char x) {
char y = toupper(x);
return (y=='A' || y=='E' || y=='I'|| y=='O'|| y=='U');
}
int main() {
cout<< isVowel('a');
return 0;