11. Implement a program to calculate the length of a string without using built-in functions.

Required Input:

std::string str = "Hello World";

Expected Output:

Length of the string = 11

Code In Cpp

#include #include int main() { std::string str = "Hello World"; // Logic to calculate string length return 0; }

Output

Click Run Button to view compiled output

12. Write a program to demonstrate the use of a struct for managing book data.

Required Input:

Define a struct Book with title, author, and price.

Expected Output:

Title: 1984
Author: George Orwell
Price: $15.99

Code In Cpp

#include #include struct Book { std::string title; std::string author; float price; }; int main() { Book book1; // Logic to manage book data return 0; }

Output

Click Run Button to view compiled output

13. Create a program to find the first non-repeating character in a string.

Required Input:

std::string str = "swiss";

Expected Output:

First non-repeating character = w

Code In Cpp

#include #include #include int main() { std::string str = "swiss"; // Logic to find first non-repeating character return 0; }

Output

Click Run Button to view compiled output

14. Implement a program to find all prime numbers up to a given number N.

Required Input:

int N = 20;

Expected Output:

Prime numbers up to 20: 2 3 5 7 11 13 17 19 

Code In Cpp

#include int main() { int N = 20; // Logic to find prime numbers return 0; }

Output

Click Run Button to view compiled output

15. Write a program to implement selection sort on an array.

Required Input:

int arr[] = {64, 25, 12, 22, 11};

Expected Output:

Sorted array: 11 12 22 25 64 

Code In Cpp

#include int main() { int arr[] = {64, 25, 12, 22, 11}; // Logic for selection sort return 0; }

Output

Click Run Button to view compiled output

16. Create a program to generate the first N terms of the arithmetic series.

Required Input:

int a = 5, d = 3, N = 10;

Expected Output:

Arithmetic series: 5 8 11 14 17 20 23 26 29 32 

Code In Cpp

#include int main() { int a = 5, d = 3, N = 10; // Logic to generate the arithmetic series return 0; }

Output

Click Run Button to view compiled output

17. Write a program to check if a string is a palindrome.

Required Input:

std::string str = "madam";

Expected Output:

String is a palindrome.

Code In Cpp

#include #include int main() { std::string str = "madam"; // Logic to check for palindrome return 0; }

Output

Click Run Button to view compiled output

18. Implement a program to perform matrix multiplication.

Required Input:

Two matrices of size 2x2.

Expected Output:

Resultant matrix after multiplication:
19 22 
43 50 

Code In Cpp

#include int main() { int A[2][2] = {{1, 2}, {3, 4}}; int B[2][2] = {{5, 6}, {7, 8}}; // Logic for matrix multiplication return 0; }

Output

Click Run Button to view compiled output

19. Write a program to demonstrate function overloading with different data types.

Required Input:

Two different overloaded functions.

Expected Output:

Integer addition: 5
Double addition: 6

Code In Cpp

#include int add(int a, int b); double add(double a, double b); int main() { // Logic to demonstrate function overloading return 0; }

Output

Click Run Button to view compiled output

20. Create a program to find the factorial of a number using recursion.

Required Input:

int n = 5;

Expected Output:

Factorial of 5 = 120

Code In Cpp

#include int factorial(int n); int main() { int n = 5; // Logic to find factorial return 0; }

Output

Click Run Button to view compiled output

ad vertical

2 of 3