Oops Ass
Oops Ass
SUBMITTED BY:
Name- ______________________
Roll No.- _____________________
Group- _______________________
INDEX
Assignment 1:
int main() {
string history[100];
int currentIndex = -1;
string content;
int choice;
string text;
do {
cout << "\nMenu:\n";
cout << "1. Add Text\n";
cout << "2. Undo\n";
cout << "3. Redo\n";
cout << "4. Display Content\n";
cout << "5. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
// Add text
cout << "Enter text to add: ";
cin.ignore();
getline(cin, text);
content += text;
case 2:
// Undo operation
if (currentIndex <= 0) {
cout << "Nothing to undo." << endl;
} else {
currentIndex--;
content = history[currentIndex];
}
break;
case 3:
// Redo operation
if (currentIndex >= 99 || history[currentIndex + 1] == "") {
cout << "Nothing to redo." << endl;
} else {
currentIndex++;
content = history[currentIndex];
}
break;
case 4:
// Display the current content
cout << "Current Content: " << content << endl;
break;
case 5:
cout << "Exiting..." << endl;
break;
default:
cout << "Invalid choice, please try again." << endl;
}
} while (choice != 5);
return 0;}
Assignment 2
a) Write a C++ program to find the sum of individual digits of a positive integer.
c) Write a C++ program to generate all the prime numbers between 1 and n,
where n is a value
supplied by the user.
d) Write a C++ program to find both the largest and smallest number in a list of
integers.
a)
#include <iostream>
using namespace std;
int main() {
int number, sum = 0;
cout << "Enter a positive integer: ";
cin >> number;