C++ Code Snippets

Dear students, last year while I'm studying C++, there are lots of snippets I've working on. And I'd like to share it with you only for educational purposes. You may download my C++ sample projects from the links below. Enjoy!


Odd and Even Numbers
void main(){ int num = 0; cout << "Please input any number:"; cin >> num; if(num/2 * 2!=num){ cout<< endl <<endl; cout<< "You entered an Odd Number" <<endl <<endl; }else{ cout<< endl <<endl; cout<< "You entered an Even Number" <<endl <<endl; } if(num<0){ cout << "You entered a Negative Number" <<endl <<endl; }else{ cout << "You entered a Positive Number" <<endl <<endl; } if(num%3==0){ cout << "The number is divisible by 3" <<endl <<endl; }else if(num%4==0){ cout << "The number is divisible by 4" <<endl <<endl; }else if(num%5==0){ cout << "The number is divisible by 5" <<endl <<endl; } }
Meralco Bill

Discount

Ordering

How many 100 are there in your given
Other snippets:

Leap Year

Gas Station

Fixed floating point




No comments:

Post a Comment