Untitled 1
Untitled 1
#include <iostream>
#include <limits.h>
class User {
public:
string nick_name;
string user_name;
string password;
string bio;
string image_uri;
int followers;
int following;
int posts;
};
// Function prototypes
int main() {
// Initialization
int rep_main = 1;
User users[MAX] = {
{"John Doe", "johndoe123", "password123", "I love programming!", "image1.jpg", 100, 50, 25},
{"Alice Smith", "alicesmith", "pass123", "Photography enthusiast", "image2.jpg", 150, 75, 30},
{"Bob Johnson", "bobj", "securepass", "Nature lover and adventurer", "image3.jpg", 80, 40, 15},
{"Eva Williams", "evaw", "mypassword", "Foodie and chef", "image4.jpg", 120, 60, 20},
{"Sam Miller", "samm", "p@ssw0rd", "Fitness freak", "image5.jpg", 200, 100, 40}
};
do {
input_jump:
cout << "1. Insert Profile\n2. Search Profile\n3. Get All Profiles\n4. Modify Profile\n5. Delete
Profile\n6. Exit The Program" << endl;
space(0);
cin.ignore();
switch(main_choice) {
case 1:
inputUser(users);
goto input_jump;
break;
case 2:
string user_search;
getline(cin, user_search);
getUser(users, user_search);
space(0);
profileOptions(users, user_search);
break;
case 3:
getAllUser(users);
space(2);
int ch;
cin.ignore();
getUserProfile(users, u);
profileOptions(users, u);
break;
case 4:
string user_mod;
modifyUserProfile(users, user_mod);
break;
case 5:
string user_del;
deleteUser(users, user_del);
break;
case 6:
break;
default:
break;
} while(rep_main == 1);
return 0;
return users[index].user_name;
// Function to display profile options (Open Profile, Modify Profile, Delete Profile)
int n;
cout << "1. Open Profile\n2. Modify Profile\n3. Delete Profile\n\nInput your choice : ";
cin >> n;
switch(n) {
case 1:
getUserProfile(users, user);
break;
case 2:
modifyUserProfile(users, user);
break;
case 3:
deleteUser(users, user);
break;
default:
int c;
User* u = &(users[index]);
cout << "Modifying User : " << u->user_name << endl << endl;
cout << "1. Name\n2. User Name\n3. Password\n4. Bio\n5. Profile Image\nInput your choice : ";
cin >> c;
cin.ignore( );
switch(c) {
case 1:
getline(cin, u->nick_name);
break;
case 2:
getline(cin, u->user_name);
break;
case 3:
getline(cin, u->password);
break;
case 4:
getline(cin, u->bio);
break;
case 5:
getline(cin, u->image_uri);
break;
default:
User u = users[index];
space(3);
space(3);
int size = 0;
int i = 0;
while(!users[i].user_name.empty()) {
size++;
i++;
return size;
return false;
else {
return true;
int user_input_count;
if(isFull(users)) {
else {
User u;
getline(cin, u.nick_name);
getline(cin, u.user_name);
getline(cin, u.password);
getline(cin, u.bio);
getline(cin, u.image_uri);
users[getSize(users)] = u;
int i = 0;
while(!users[i].user_name.empty()) {
if(users[i].user_name == user_name) {
return i;
i++;
return INT_MIN;
int i = index;
i++;
users[i] = empty;
User u = users[index];
cout << "( " << index + 1 << " )" << "__" << u.user_name << " _________________" << endl;
getUser(users, users[i].user_name);
void space(int n) {
if(n == 2) {
else if(n == 3) {
else if(n == 4) {
else {
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
int main() {
char username[50];
char password[50];
int i;
char arr[] =
"##########################################################################";
clrscr();
lineto(0, 500);
moveto(625, 0);
lineto(625, 500);
gotoxy(4, 25);
gotoxy(4, 5);
fail:
gotoxy(35, 13);
gotoxy(35, 14);
gotoxy(35, 15);
cho = getch();
gotoxy(35, 13);
gotoxy(35, 14);
gotoxy(35, 15);
switch (cho) {
gotoxy(31, 13);
gotoxy(31, 15);
gotoxy(42, 13);
gotoxy(42, 15);
c = getch( );
if (c == 13) {
password[i] = '\0';
break;
password[i] = c;
delay(200);
gotoxy(31, 13);
gotoxy(31, 15);
gotoxy(30, 14);
gotoxy(78, 5);
delay(15);
delay(50);
delay(20);
gotoxy(4, 25);
delay(15);
delay(30);
gotoxy(30, 14);
gotoxy(30, 14);
gotoxy(32, 15);
} else {
gotoxy(30, 14);
gotoxy(30, 14);
gotoxy(27, 15);
delay(2000);
gotoxy(30, 14);
gotoxy(27, 15);
goto fail;
break;
gotoxy(31, 13);
gotoxy(31, 15);
gotoxy(42, 13);
gotoxy(46, 15);
gotoxy(31, 13);
gotoxy(31, 15);
gotoxy(30, 14);
gotoxy(27, 15);
delay(2000);
gotoxy(30, 14);
gotoxy(27, 15);
goto fail;
for '3'
exit(0);
break;
press
return 0;
#include <iostream>
class Shape {
public:
};
private:
double side;
public:
Square(double s) : side(s) { }
return 4 * side;
};
private:
double length;
double breadth;
public:
};
// Derived class representing a circle
private:
double radius;
public:
Circle(double r) : radius(r) { }
};
int main( ) {
Circle circle(5);
Square square(4);
cout << "Rectangle Area: " << rectangle.area( ) << ", Perimeter: " << rectangle.perimeter( ) << endl;
cout << "Circle Area: " << circle.area( ) << ", Perimeter: " << circle.perimeter( ) << endl;
cout << "Square Area: " << square.area( ) << ", Perimeter: " << square.perimeter( ) << endl;
_getch( );
return 0;
BANK PROGRAM
#include <iostream>
#include <cstring>
class Account {
protected:
char name[30];
int age;
long long int acc_no; // Changed to long long int for larger range
int interest;
int balance;
public:
strcpy(name, n);
void setAge(int a) {
age = a;
acc_no = an;
void setInterest(int i) {
interest = i;
void setBalance(int b) {
balance = b;
return name;
int getAge( ) {
return age;
long long int getAccountNum( ) { // Changed return type to long long int
return acc_no;
int getInterest( ) {
return interest;
int getBalance( ) {
return balance;
};
public:
void createUser( ) {
cin.getline(name, 30);
void getUserInfo( ) {
int getUserBalance( ) {
return balance;
};
public:
void createUser( ) {
cin.getline(name, 30);
void getUserInfo( ) {
int getUserBalance( ) {
return balance;
};
class User {
private:
SavingsAccount savingsAccount;
CurrentAccount currentAccount;
bool hasSavings;
bool hasCurrent;
public:
User( ) {
hasSavings = false;
hasCurrent = false;
void createAccounts( ) {
cout << "\n1. Create Savings Account\n2. Create Current Account\n3. Create Both\nEnter your
choice: ";
int choice;
switch (choice) {
case 1:
savingsAccount.createUser( );
hasSavings = true;
break;
case 2:
currentAccount.createUser( );
hasCurrent = true;
break;
case 3:
savingsAccount.createUser( );
currentAccount.createUser( );
hasSavings = true;
hasCurrent = true;
break;
default:
int getBalance( ) {
return balance;
};
public:
void createUser( ) {
cin.getline(name, 30);
void getUserInfo( ) {
if (hasSavings) {
savingsAccount.getUserInfo( );
if (hasCurrent) {
currentAccount.getUserInfo( );
int getSavingsBalance( ) {
int getCurrentBalance( ) {
bool searchByAccountNum(long long int accountNum) { // Changed parameter type to long long int
};
int main( ) {
User users[10];
int count = 0;
int choice;
while (true) {
cout << "\n1. Create New User\n2. View User Info\n3. View Savings Account Balance\n4. View
Current Account Balance\n5. Search by Account Number\n6. Exit\nEnter your choice: ";
switch (choice) {
case 1: {
users[count].createAccounts( );
count++;
else {
break;
case 2: {
int index;
users[index].getUserInfo( );
else {
break;
case 3: {
int index;
cout << "Savings Account Balance: " << users[index].getSavingsBalance( ) << endl;
else {
break;
case 4: {
int index;
cout << "Current Account Balance: " << users[index].getCurrentBalance( ) << endl;
else {
break;
case 5: {
if (users[i].searchByAccountNum(accountNum)) {
users[i].getUserInfo();
found = true;
break;
if (!found)
break;
case 6:
return 0;
default:
return 0;
void getUserInfo() {
int getUserBalance() {
return balance;
};
public:
void createUser( ) {
cin.getline(name, 30);
void getUserInfo( ) {
int getUserBalance( ) {
return balance;
};
class User {
private:
SavingsAccount savingsAccount;
CurrentAccount currentAccount;
bool hasSavings;
bool hasCurrent;
public:
User( ) {
hasSavings = false;
hasCurrent = false;
void createAccounts( ) {
cout << "\n1. Create Savings Account\n2. Create Current Account\n3. Create Both\nEnter your
choice: ";
int choice;
switch (choice) {
case 1:
savingsAccount.createUser( );
hasSavings = true;
break;
case 2:
currentAccount.createUser( );
hasCurrent = true;
break;
case 3:
savingsAccount.createUser();
currentAccount.createUser();
hasSavings = true;
hasCurrent = true;
break;
default:
void getUserInfo() {
if (hasSavings) {
savingsAccount.getUserInfo();
if (hasCurrent) {
currentAccount.getUserInfo();
int getSavingsBalance() {
int getCurrentBalance() {
bool searchByAccountNum(long long int accountNum) { // Changed parameter type to long long int
};
int main() {
User users[10];
int count = 0;
int choice;
while (true) {
cout << "\n1. Create New User\n2. View User Info\n3. View Savings Account Balance\n4. View
Current Account Balance\n5. Search by Account Number\n6. Exit\nEnter your choice: ";
switch (choice) {
case 1: {
users[count].createAccounts();
count++;
else {
break;
case 2: {
int index;
users[index].getUserInfo();
else {
break;
case 3: {
int index;
cout << "Savings Account Balance: " << users[index].getSavingsBalance() << endl;
else {
break;
case 4: {
int index;
cout << "Current Account Balance: " << users[index].getCurrentBalance() << endl;
else {
break;
case 5: {
if (users[i].searchByAccountNum(accountNum)) {
users[i].getUserInfo( );
found = true;
break;
if (!found)
break;
case 6:
return 0;
default:
return 0;
PATTERN PROGRAM
#include <iostream>
class binaryPattern {
public:
void pattern1(int n) {
cout << 1 ;
void pattern2(int n) {
void pattern3(int n) {
void pattern4(int n) {
((i % 2 == 0 && (j == 0 || j == n - 1)) || (i % 2 != 0) && (j != 0 && j != n - 1)) ? cout << 0 : cout << 1;
void pattern5(int n) {
for(int i = 0;i < n;i++) {
void pattern6(int n) {
};
class numericPattern {
public:
void pattern1(int n) {
cout << i + 1;
void pattern2(int n) {
cout << j + 1;
void pattern3(int n) {
cout << j + 1 + i;
}
cout << endl;
void pattern4(int n) {
cout << j + 1 + i;
};
int main() {
binaryPattern bp;
numericPattern np;
bp.pattern1(5);
bp.pattern2(5);
bp.pattern3(5);
bp.pattern4(5);
bp.pattern5(5);
bp.pattern6(5);
np.pattern1(5);
np.pattern2(5);
np.pattern3(5);
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <windows.h>
#include <conio.h>
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
// Structure to represent the start and end points of snakes and ladders
struct Way {
int start;
int end;
};
class SnakeLadder {
private:
public:
SnakeLadder() {
playerOne = 0;
playerTwo = 0;
chance = 0;
void printBoard() {
system("cls");
cout << "**********SNAKES AND LADDERS*********" << endl << endl << endl;
if (playerOne == num) {
} else {
int rollDice() {
int lb = 1;
int ub = 6;
srand(time(0));
return roll;
if (snakes[i].start == player) {
break;
if (ladders[i].start == player) {
break;
void startGame() {
while (true) {
break;
break;
}}};
int main() {
return 0;
#include <cmath>
class Array2D {
private:
public:
rows = sqSize;
if (size != c) {
data[i][j] = arr[c];
c++;
} else {
// If the 1D array is smaller than the 2D array, fill remaining elements with 0
data[i][j] = 0;
void print() {
cout << data[i][j] << "\t"; // Output each element of the array
cout << endl; // Move to the next line after printing each row
~Array2D() {
delete[] data[i];
delete[ ] data;
};
int main( ) {
// Create an object of the Array2D class and initialize it with the 1D array
array2D.print( );
return 0;
int main( ) {
int lb = 1000, ub = 9999; // Lower and upper bounds for the OTP range
srand(time(1));
int userNumber;
// Check if the user's input matches the generated OTP and if the time limit has not expired
} else {
return 0;
EXCEL FUNCTIONS
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cctype>
#include <cmath>
// Using the standard namespace to avoid writing std:: before standard library functions
class Text {
public:
void runTextFunctions( ) {
int choice;
double value;
bool isEqual;
switch (choice) {
case 1:
break;
case 2:
break;
case 3:
cout << "Texts are " << (isEqual ? "equal" : "not equal") << endl;
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
break;
default:
strcpy(result, text1);
strcat(result, text2);
char format[20];
if (found)
else
return -1;
result[count] = '\0';
strcpy(result, text);
else
strcpy(result, text);
result[i] = tolower(result[i]);
void MID(const char* text, int start, int number, char* result) {
result[number] = '\0';
strcpy(result, text);
if (result[0] != '\0') {
result[0] = toupper(result[0]);
while (isspace(text[start]))
start++;
end--;
};
class Numbers {
public:
void runNumberFunctions() {
int choice;
switch (choice) {
case 1: {
int count;
cout << "Enter " << count << " numbers: ";
delete[] numbers;
break;
case 2: {
int count;
cout << "Enter " << count << " numbers: ";
delete[] numbers;
break;
case 3: {
int count;
cout << "Enter " << count << " numbers: ";
delete[] numbers;
break;
case 4: {
int count;
cout << "Enter " << count << " numbers: ";
delete[ ] numbers;
break;
case 5: {
int count;
break;
case 6: {
float number;
int decimals;
break;
case 7: {
int number;
break;
case 8: {
float number;
break;
case 9: {
break;
case 10: {
break;
default:
int sum = 0;
sum += numbers[i];
return sum;
if (count == 0)
return 0.0f;
if (count == 0)
return 0;
min = numbers[i];
return min;
if (count == 0)
return 0;
max = numbers[i];
return max;
return count;
return abs(number);
if (number < 0)
return NAN;
return sqrt(number);
if (denominator == 0)
return 0;
};
int main( ) {
int choice;
// Displaying menu options for choosing between text and number functions
switch (choice) {
case 1: {
Text text;
text.runTextFunctions( );
break;
case 2: {
Numbers numbers;
numbers.runNumberFunctions( );
break;
default:
return 0;
IKEA PROGRAM
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define REV
// Using the struct Perm as a string data type using a character array inside
typedef struct {
wchar_t word[300];
} Perm;
// Using preprocessor directive #ifdef to check if REV is defined earlier in the code
// Then define the comparator for the qsort accordingly if REV defined using
// descending comparator
#ifdef REV
// wcscmp returns the difference between the first and second parameter
// If two words 'CAR' and 'RAC' are compared, it will compare all the characters
// Then, when it encounters the different characters, it will compare their ASCII values
// In this case, it will return a positive value because the ASCII code of 'R' will be greater
#else
// and cannot be modified through this pointer. It's a safety measure to prevent
// type that can point to any data type, but the compiler doesn't know the exact
#endif
// The swap function we are using to generate the permutation of a given word
arr[i] = arr[j];
arr[j] = temp;
i
IKEA PROGRAM
nt main() {
// This is the buffer we are using to read lines from the file
wchar_t buff[300];
FILE *file;
int len,i,k,j;
Perm permutations[5];
if (file == NULL) {
exit(1);
// Using the wcslen function to calculate the length of the word in the buffer
// Remove the newline character at the end of every string in the buffer
// If we don't use this, every string permutation will also contain a newline character
buff[wcslen(buff) - 1] = '\0';
len = wcslen(buff);
Perm permuted;
wcscpy(permuted.word, buff);
j = rand() % len;
swap(permuted.word, i, j);
permutations[k] = permuted;
// Using qsort by giving the array base address, array size, byte size of array
printf("\n\n");
IKEA PROGRAM
fclose(file);
return 0;
}