fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. // Print From 1 to N
  7. int n;
  8. cout << "Enter N: ";
  9. cin >> n;
  10.  
  11. for (int i = 1; i <= n; i++) {
  12. cout << i << " ";
  13. }
  14. cout << endl;
  15.  
  16.  
  17. // Reverse a Number
  18. int num, rev = 0;
  19. cout << "Enter a number: ";
  20. cin >> num;
  21.  
  22. while (num > 0) {
  23. int digit = num % 10;
  24. rev = rev * 10 + digit;
  25. num /= 10;
  26. }
  27.  
  28. cout << "Reversed: " << rev;
  29. cout << endl;
  30.  
  31.  
  32. // Input Until User Enters 0
  33. int x;
  34.  
  35. do {
  36. cout << "Enter a number 0 to stop: \n";
  37. cin >> x;
  38. } while (x != 0);
  39.  
  40. cout << "Loop Stoped.\n";
  41.  
  42.  
  43. // Build a 90° Triangle
  44. int l;
  45. cout << "Enter number of rows: \n";
  46. cin >> l;
  47.  
  48. for (int i = 1; i <= l; i++) {
  49. for (int j = 1; j <= i; j++) {
  50. cout << "*";
  51. }
  52. cout << endl;
  53. }
  54. cout << endl;
  55.  
  56.  
  57. return 0;
  58. }
Success #stdin #stdout 0s 5308KB
stdin
8
34567
2 5 6 0
5
stdout
Enter N: 1 2 3 4 5 6 7 8 
Enter a number: Reversed: 76543
Enter a number 0 to stop:  
Enter a number 0 to stop:  
Enter a number 0 to stop:  
Enter a number 0 to stop:  
Loop Stoped.
Enter number of rows:  
*
**
***
****
*****