Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. #include <iostream>
  2. #include<stdlib.h>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. void Get_The_Consecutive_Sum()
  7. {
  8. system("cls");
  9. int first,second,total;
  10.  
  11. cout << " Get the Consecutive Sum of Two Numbers.\n";
  12. cout << "Enter Fisrt Number :";
  13. cin >> first ;
  14. cout << "Enter Second Number :";
  15. cin >> second;
  16.  
  17. if (first > second)
  18. {
  19. for ( int i = second; i <= first; i++)
  20. {
  21. total= total + i;
  22. }
  23. }
  24. else
  25. {
  26. for (int i= first; i<=second; i++)
  27. {
  28. total = total +i;
  29. }
  30.  
  31. }
  32. cout << "Total is :" << total << endl << endl;
  33.  
  34. }
  35.  
  36. void get_hours_minutes_seconds()
  37. {
  38. system("cls");
  39. int seconds,hours,minutes,sec;
  40.  
  41. cout << " Get the equivalent hours,minutes,and seconds from seconds.\n";
  42. do
  43. {
  44. cout << "Enter number of seconds :";
  45. cin >> seconds;
  46. if (seconds <0)
  47. cout<< "Number cannot be negative.Try again.\n";
  48. }
  49. while (seconds < 0);
  50.  
  51. hours = seconds/ 60/60;
  52. minutes = seconds % (60*60) / 60;
  53. sec = seconds % 60;
  54.  
  55. cout << "Hours :" << hours << endl << endl;
  56. cout << "minutes :" << minutes << endl << endl;
  57. cout << "Seconds :" << sec << endl << endl;
  58. }
  59. void multiplying_without_Multiply_operand()
  60. {
  61. system ("cls");
  62. int multiplicand,multiplier,product;
  63.  
  64. cout << "Multiplying without using multiply operand";
  65. cout << "Enter First Number (multiplicand)";
  66. cin >> multiplicand;
  67. cout << "Enter Second Number (multiplier)";
  68. cin >> multiplier;
  69.  
  70. for (int i =1 ; i <= multiplier; i++)
  71. {
  72. product += multiplicand;
  73.  
  74. }
  75. cout << " The product is : " << product << endl << endl;
  76. }
  77. void Odd_Number_Divisible_By_3 ()
  78. {
  79. system("cls");
  80. int number;
  81.  
  82. cout <<" Check if the number is divisible by 3" << endl << endl;
  83. do
  84. {
  85. cout << "Enter number :";
  86. cin >> number;
  87. if (number % 2 ==0)
  88. cout << "Number is an even number. Try again." << endl << endl;
  89. }
  90. while (number % 2 == 0);
  91.  
  92. if (number % 3 == 0)
  93. cout << "The number is divisible by 3";
  94.  
  95. else
  96. cout << "The number is not divisible by 3";
  97.  
  98. }
  99. int main ()
  100. {
  101. int menu;
  102. do
  103. {
  104. system("cls");
  105. cout << "Choose from the menu below.\n";
  106. cout << "[1] Get The Consecutive Sum.\n";
  107. cout << "[2] Get hours minutes seconds.\n";
  108. cout << "[3] Multiplying without Multiply operand.\n";
  109. cout << "[4] Odd Number Divisible By 3.\n";
  110. cout << "[5] Exit.\n";
  111. cout << " Select Number :";
  112. cin >> menu;
  113.  
  114. switch(menu)
  115. {
  116. case 1:
  117. Get_The_Consecutive_Sum ();
  118. break;
  119.  
  120. case 2:
  121. get_hours_minutes_seconds();
  122. break;
  123. case 3:
  124. multiplying_without_Multiply_operand();
  125. break;
  126. case 4:
  127. Odd_Number_Divisible_By_3();
  128. break;
  129. default:
  130. cout << "Invalid Menu";
  131.  
  132.  
  133. }
  134. system ("pause");
  135. } while (menu!=5);
  136. {
  137. }
  138. system ("cls");
  139. cout << endl << " Thank You Fo Using!" << endl << endl ;
  140. cout << endl << " Enjoy Your Day." << endl << endl;
  141. return 0 ;
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement