Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<stdlib.h>
- #include <cstdlib>
- using namespace std;
- void Get_The_Consecutive_Sum()
- {
- system("cls");
- int first,second,total;
- cout << " Get the Consecutive Sum of Two Numbers.\n";
- cout << "Enter Fisrt Number :";
- cin >> first ;
- cout << "Enter Second Number :";
- cin >> second;
- if (first > second)
- {
- for ( int i = second; i <= first; i++)
- {
- total= total + i;
- }
- }
- else
- {
- for (int i= first; i<=second; i++)
- {
- total = total +i;
- }
- }
- cout << "Total is :" << total << endl << endl;
- }
- void get_hours_minutes_seconds()
- {
- system("cls");
- int seconds,hours,minutes,sec;
- cout << " Get the equivalent hours,minutes,and seconds from seconds.\n";
- do
- {
- cout << "Enter number of seconds :";
- cin >> seconds;
- if (seconds <0)
- cout<< "Number cannot be negative.Try again.\n";
- }
- while (seconds < 0);
- hours = seconds/ 60/60;
- minutes = seconds % (60*60) / 60;
- sec = seconds % 60;
- cout << "Hours :" << hours << endl << endl;
- cout << "minutes :" << minutes << endl << endl;
- cout << "Seconds :" << sec << endl << endl;
- }
- void multiplying_without_Multiply_operand()
- {
- system ("cls");
- int multiplicand,multiplier,product;
- cout << "Multiplying without using multiply operand";
- cout << "Enter First Number (multiplicand)";
- cin >> multiplicand;
- cout << "Enter Second Number (multiplier)";
- cin >> multiplier;
- for (int i =1 ; i <= multiplier; i++)
- {
- product += multiplicand;
- }
- cout << " The product is : " << product << endl << endl;
- }
- void Odd_Number_Divisible_By_3 ()
- {
- system("cls");
- int number;
- cout <<" Check if the number is divisible by 3" << endl << endl;
- do
- {
- cout << "Enter number :";
- cin >> number;
- if (number % 2 ==0)
- cout << "Number is an even number. Try again." << endl << endl;
- }
- while (number % 2 == 0);
- if (number % 3 == 0)
- cout << "The number is divisible by 3";
- else
- cout << "The number is not divisible by 3";
- }
- int main ()
- {
- int menu;
- do
- {
- system("cls");
- cout << "Choose from the menu below.\n";
- cout << "[1] Get The Consecutive Sum.\n";
- cout << "[2] Get hours minutes seconds.\n";
- cout << "[3] Multiplying without Multiply operand.\n";
- cout << "[4] Odd Number Divisible By 3.\n";
- cout << "[5] Exit.\n";
- cout << " Select Number :";
- cin >> menu;
- switch(menu)
- {
- case 1:
- Get_The_Consecutive_Sum ();
- break;
- case 2:
- get_hours_minutes_seconds();
- break;
- case 3:
- multiplying_without_Multiply_operand();
- break;
- case 4:
- Odd_Number_Divisible_By_3();
- break;
- default:
- cout << "Invalid Menu";
- }
- system ("pause");
- } while (menu!=5);
- {
- }
- system ("cls");
- cout << endl << " Thank You Fo Using!" << endl << endl ;
- cout << endl << " Enjoy Your Day." << endl << endl;
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement