Write a C++ program to print 'Hello World!' on screen

Output :

    Hello world !
                    

Write a C++ program to print the sum of two numbers

Output :

    Enter number 1 : 45
    Enter number 2 : 96
                        
    The sum of 45 and 96 is 141
                    

Write a C++ program that takes two numbers and display the product of two numbers

Output :

    Enter number 1 : 25
    Enter number 2 : 40
                        
    The product of 25 and 40 is 1000
                    

Write a C++ program to print the sum, multiply, subtract, divide and remainder of two numbers

Output :

    Enter number 1 : 18
    Enter number 2 : 25
                        
    The sum of 18 and 25 is 43
    The difference of 18 and 25 is -7
    The product of 18 and 25 is 450
    The remainder of 18 and 25 is 18
                    

Write a C++ program that takes five numbers as input to calculate and print the average of the numbers

Output :

    Enter number 1 : 5
    Enter number 2 : 10
    Enter number 3 : 15
    Enter number 4 : 20
    Enter number 5 : 25
    
    The average for given 5 numbers is : 15
                    

Write a C++ program to swap two variables

Output :

    Enter number1 : 100
    Enter number2 : 200
    Before swaping using third variable --
    
    Number 1 : 100 Number 2 : 200
    After swaping --
    Number 1 : 200 Number 2 : 100

    Before swaping without using third variable --
    Number 1 : 200 Number 2 : 100
    After swaping --
    Number 1 : 100 Number 2 : 200
                    

Write a C++ program to convert a decimal number to binary numbers

Output :

    Enter a number to convert it into binary : 100
    100 in binary format 1100100

    Enter a number to convert it into binary : 50
    50 in binary format 110010
                    

Write a C++ program to convert a binary number to decimal number

Output :

    Enter a number to convert it into binary : 10010011
    10010011 in decimal format : 147

    Enter a number to convert it into binary : 100
    100 in decimal format : 4
                    

Write a C++ program to check whether C++ is installed on your computer or not

Output :

    C++ compiler is installed
                    

Write a C++ program and compute the sum of the digits of an integer

Output :

    Enter the number to get its digits sum : 54625
                        
    The sum of the digits in 54625 = 22
                    

Write a C++ program to compare two numbers

Output :

    Enter the value for number 1 : 45
    Enter the value for number 2 : 42
    45 is greater than 42
                    

Write a C++ program to count the letters, spaces, numbers and other characters of an input string

Output

    Enter your input string : my name is sHanaya1243423@@./
    
    No. of numbers in string : 7
    No. of spaces in string : 3
    No. of letters in string : 15
    No. of others in string : 4
                    

Write a C++ program to print the ascii value of a given character

Output

    Enter a character to get its ASCII value : s
    The ASCII value of s is 115

    Enter a character to get its ASCII value : A
    The ASCII value of A is 65
                    

Write a C++ program that accepts an integer (n) and computes the value of n+nn+nnn

Output

    Enter a number : 5
    
    The value of n + nn + nnn : 155
                    

Write a C++ program to display the system time

Output

    Current system time is : Wed Mar 27 23:13:00 2024
                    

Write a C++ program to print the odd numbers from 1 to 20

Output :

    Odd numbers from 1 to 20 :
    1
    3
    5
    7
    9
    11
    13
    15
    17
    19
                    

Write a C++ program to print the even numbers from 1 to 20

Output :

    Even numbers from 1 to 20 :
    0
    2
    4
    6
    8
    10
    12
    14
    16
    18
    20
                    

Write a C++ program to convert a string to an integer

Output :

    Enter a string representing an integer: 456
    Enter a string to convert into an integer : 456
                    

Write a C++ program to convert seconds to hour, minute and seconds

Output :

    Enter seconds to convert the time into hours and minutes : 5000

    Time: 1 hours and 23 minutes
                    

Write a C++ program to compute the sum of the first 100 prime numbers

Output

    Sum of the first 100 prime numbers : 1060
                    

Write a C++ program to compute the square root of an given integer

Output

    Enter a number : 16
    Square root of 16 is 4
    
    Enter a number : 5
    Square root of 5 is 2.23607
                    

Write a C++ program to check if a positive number is a palindrome or not

Output

    Enter a number to check is it palindrome or not : 20002
    20002 is a palindrome.

    Enter a number to check is it palindrome or not : 20052
    20052 is not a palindrome.
                    

Write a C++ program to add two numbers without using any arithmetic operators

Output

    Enter number 1 : 100
    Enter number 2 : 200
    
    The sum of 100 and 200 : 300
                    

Write a C++ program to add all the digits of a given positive integer

Output

    Enter a positive number to get its digits sum : 12313
    
    The sum of the digits in 12313 = 10
                    

C++ program to find area of circle

Output

    Enter the radius of circle in cm : 15
    The area of circle of radius 15 is : 706.5cm²
                    

C++ Program to find areaof rectangle

Output

    Enter the length of rectangle in cm : 40
    Enter the breadth of rectangle in cm : 80
    
    The area of rectangle of length 40and breadth 80 is : 3200cm²
                    

C++ Program to find areaof triangle

Output

    Enter the length of base of triangle in cm : 30
    Enter the height of triangle in cm : 18
    
    The area of rectangle of length 30and breadth 18 is : 270cm²
                    

C++ Program to find area of equilateral triangle

Output

    Enter the length of side of equilateral triangle in cm : 5
    The area of equilateral triangle off side 5cm : 10.8253cm²
                    

C++ Program to find area of rhombus

Output

    Enter the length of first diagonal of rhombus in cm : 8
    Enter the length of second diagonal of rhombus in cm : 16
    
    The area of rhombus is : 64cm²
                    

C++ Program to find area of parallelogram

Output

    Enter the length of base of parallelogram in cm : 50
    Enter the height of parallelogram in cm : 48
    
    The area of parallelogram of length 50and breadth 48 is : 2400cm²
                    

C++ Program to find area of Prism

Output

    Enter the length of height of prism in cm² : 30
    Enter the length of height of prism in cm² : 4
    
    The area of prism is : 120cm²
                    

C++ Program to find volume of sphere

Output

    Enter the radius of sphere in cm : 18
    
    The volume of sphere of radius 18 is : 17496cm²
                    

C++ Program to find volume of cylinder

Output

    Enter the radius of cylinder in cm : 15
    Enter the height of cylinder in cm : 26
                        
    The volume of cylinder of radius 15 is : 17550cm³
                    

C++ Program to find volume of cuboid

Output

    Enter the length of cuboid in cm : 12
    Enter the breadth of cuboid in cm : 45
    Enter the height of cuboid in cm : 15
    
    The volume of cuboid of length 12cm ,breadth 45cm and height 15cm is : 8100cm³
                    

C++ Program to find volume of cone

Output

    Enter the radius of cone in cm : 12
    Enter the height of cone in cm : 19
    
    The volume of cone of radius 12cm and height of 19cm is : 2866.29cm³
                    

C++ program to find surface area of cuboid

Output

    Enter the length of cuboid in cm : 45
    Enter the breadth of cuboid in cm : 12
    Enter the height of cuboid in cm : 2.6
    
    The total surface area of cuboid is : 1376.4cm²
                    

C++ program to find surface area of cylinder

Output

    Enter the radius of cylinder in cm : 8.3
    Enter the height of cylinder in cm : 5
    
    The total surface area of cylinder is : 1033.35cm²
                    

C++ program to find surface area of cube

Output

    Enter the length of side cube in cm : 50
    
    The total surface area of cube is : 15000cm²
                    

C++ program to calculate average marks

Output

    Enter total number of subjects : 3

    Enter the marks of subject 1 : 54
    Enter the marks of subject 2 : 26
    Enter the marks of subject 3 : 75

    The average marks of 3 subjects : 51.6667
                    

C++ program to check vowel or consonant

Output

    Enter character to check if it is a vowel or consonant : A
    A is a vowel

    Enter character to check if it is a vowel or consonant : k
    k is a consonant
                    

C++ program to sum of N numbers

Output

    Enter the number of upto which sum to be calculated : 10
    The sum of numbers upto 10 is : 55

    Enter the number of upto which sum to be calculated : 5
    The sum of numbers upto 5 is : 15
                    

C++ program to find factorial of any number

Output

    Enter a number to find its factorial : 5
    The factorial of 5 is : 120

    Enter a number to find its factorial : 10
    The factorial of 10 is : 3628800
                    

C++ Program to calculate electricity bill

Output

    ------Electricity Bill------

    Enter the amount for per unit of electricity : 20
    Enter the units of electricity used by you in a month : 200
    
    Your electricity bill for this month is : 4000Rs.
                    

C++ Program To Calculate CGPA from Percentage

Output

    Enter percentage to get its CGPA : 89
    CGPA of 89 percentage : 9.36842

    Enter percentage to get its CGPA : 76
    CGPA of 76 percentage : 8
                    

C++ Program to calculate compound interest

Output

    Enter the principal rate of interest : 40000
    Enter the rate of interest : 20
    Enter the time taken of interest in years : 2
    
    The amount of compound interest for 40000Rs is : 17600Rs
                    

C++ Program To Calculate Batting Average

Output

    Enter total runs scored: 150
    Enter total innings played: 6
    Batting Average: 25
                    

C++ Program to Calculate Commission Percentage

Output

    Enter the sales amount: 50000
    Enter the commission rate (%): 5
    Commission: 2500

                    

C++ Program To Find Distance Between Two Points

Output

    Enter the value of x coordinate 1st point : 3
    Enter the value of x coordinate 2nd point : 4
    Enter the value of y coordinate 1st point : 4
    Enter the value of x coordinate 2nd point : 3
    
    The distance between coordinates (3, 4) and (4, 3) is : 1.41421cm
                    

C++ Program To CalculatePower Of Number

Output

    Enter number : 5
    Enter power : 3
    The value of 5 raised to power 3 : 125
                    

Write a C++ program to take three numbers from the user and print the greatest number

Output

    Enter number 1 : 45
    Enter number 1 : 62
    Enter number 3 : 48
    The greatest number is : 62
                    

Write a C++ program to find the number of days in a month

Output

    January : 1
    February : 2
    March : 3
    April : 4
    May : 5
    June : 6
    July : 7
    August : 8
    September : 9
    October : 10
    November : 11
    December : 12
    
    Enter the month (1-12): 3
    Enter the year: 2024
    No. of days in the 3 month of year 2024 = 31
                    

Write a C++ program to test a number is positive or negative

Output

    Enter a number to check if it is positive or negative : -45
    -45 is a negative number

    Enter a number to check if it is positive or negative : 23
    23 is a positive number
                    

Write a C++ Program to accept number of week's day (1-7) and print name of the day

Output

    Enter the number to know its corresponding day name : 5
    5 day of the week is Friday

    Enter the number to know its corresponding day name : 3
    3 day of the week is Wednesday
                    

Write a C++ program that takes a year from user and print whether that year is a leap year or not

Output

    Enter the year : 2024
    2024 is a leap year

    Enter the year : 2025
    2025 is not a leap year
                    

Write a C++ program to input 5 numbers from keyboard and find their sum and average

Output

    Enter number 1 : 25
    Enter number 2 : 12
    Enter number 3 : 45
    Enter number 4 : 20
    Enter number 5 : 4
    The sum of given 5 numbers is : 106
    The average for given 5 numbers is : 21.2
                    

Write a program in C++ to display the first 5 natural numbers

Output

    First 5 natural numbers are :
    1
    2
    3
    4
    5
                    

Output

    Enter character to check if it is a vowel or consonant : u
    u is a vowel
    
    Enter character to check if it is a vowel or consonant : s
    s is a consonant
                    

Write a C++ program to display the cube of the number upto given an integer

Output

    Enter upto which digit cubes to be showed : 5
    Cube of 1 is : 1
    Cube of 2 is : 8
    Cube of 3 is : 27
    Cube of 4 is : 64
    Cube of 5 is : 125
                    

Write a C++ program to display the n terms of odd natural number and their sum

Output

    Terms of odd natural numbers : 20
    
    1
    3
    5
    7
    9
    11
    13
    15
    17
    19
    The sum of odd natural numbers upto 20 : 100
                    

Write a C++ program to display the multiplication table of a given integer

Output

    Multiplication table of : 8
    8 X 0 = 0
    8 X 1 = 8
    8 X 2 = 16
    8 X 3 = 24
    8 X 4 = 32
    8 X 5 = 40
    8 X 6 = 48
    8 X 7 = 56
    8 X 8 = 64
    8 X 9 = 72
    8 X 10 = 80
                    

Write a C++ program that reads an integer and check whether it is negative, zero, or positive

Output

    Enter an integer: 56
    The number is positive.
                    

Write a C++ program that reads an positive integer and count the number of digits

Output

    Enter a number: 654613
    The number contains 6 digits.
                    

Write a C++ program that accepts three numbers and check All numbers are equal or not

Output

    Enter number 1 : 45
    Enter number 2 : 45
    Enter number 3 : 48

    All numbers are not equal....
                    

Write a C++ program that accepts three numbers from the user and check if numbers are in "increasing" or "decreasing" order.

Output

    Enter number 1 : 45
    Enter number 2 : 65
    Enter number 3 : 89

    The numbers are in increasing order.
                    

Write a C++ program that determines a student's grade (81-100 : A, 61-80 : B, 41-60 : C, 0-40 : D)

Output

    Enter your marks : 68
    You have gained B grade....
                    

Write a C++ program to create a simple calculator (1. ADDITION, 2. SUBTRACTION, 3. MULTIPLICATION, 4. DIVISION, 5. EXPONENTIAL, 6. PERCENTAGE, 7. EXIT)

Output

                CALCULATOR
    1. Addition
    2. Subtraction
    3. Multiplication
    4. Division
    5. Exponential
    6. Percentage
    7. Exit
    
    Enter your choice (1-7): 3
    Enter number 1: 45
    Enter number 2: 9
    Result: 405
                    

Write a C++ program to concatenate two string

Output

    Enter string 1 : hello
    Enter string 2 : world
    
    After concatenation of string 1 and string 2 : helloworld
                    

Write a C++ program to convert all characters in a string to lowercase

Output

    Enter string to convert all to lowercase : SAnju
    sanju to lowercase : sanju
                    

Write a C++ program to convert all characters in a string to uppercase

Output

    Enter string to convert all to uppercase : sanju
    SANJU to Uppercase : SANJU
                    

Write a C++ program to trim a string (remove whitespaces)

Output

    Enter a string:        hello world
    Trimmed string: hello world
                    

Write a C++ program to get a substring of a given string between two specified positions

Output

    Enter the string : helllloworldddd
    Enter the first point from where the string to be substringed : 1
    Enter the second point to where the string to be substringed : 8
    
    Substring : ellllowo
                    

Write a C++ program to replace all the 'd' characters with 'f' characters

Output

    Enter a string: doodle doodle
    String after replacing 'd' with 'f': foofle foofle

                    

Write a C++ program to get the length of a given string

Output

    Enter a string : hello

    The length of string hello is : 5
                    

Write a C++ program to print current date and time in the specified format

Output

    Choose the time format:
    1. 12-hour format
    2. 24-hour format

    Enter your choice (1 or 2): 1
    Current date and time (12-hour format): 03/31/2024 11:06:15 AM
                    

Write a C++ program to get the character at the given index within the String

Output

    Enter a string : helllo world!!!!!
    Enter index to get its corresponding character : 9
    Character at index 9: r
                    

Write a C++ program to remove a particular character from a string

Output

    Enter a String : hellbo

    Enter character to be removed from string : b
    After removing : hello
                    

Write a C++ program to reverse a String

Output

    Enter a string : hello world!!!!!

    hello world!!!!! After reversing : !!!!!dlrow olleh
                    

Write a C++ program to remove html tags from a string

Output

    Original HTML: 

This is a sample HTML string.

After removing HTML tags: This is a sample HTML string.

Write a C++ program to count total number of lines from a string

Output

    Original text:
    This is line 1.
    This is line 2.
    This is line 3.
    Total number of lines: 3

                    

Write a C++ Program to Accept the Marks of a Student and find Total Marks and Percentage

Output

    Number of subjects : 5
    Enter marks of subject 1 : 78
    Enter marks of subject 2 : 80
    Enter marks of subject 3 : 91
    Enter marks of subject 4 : 96
    Enter marks of subject 5 : 77

    Total marks : 422
    Your percentage : 84.4%
                    

Write a C++ program to print numbers from 1 to 10 using loop

Output

    Numbers from 1 to 10 :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
                    

Write a C++ program to calculate the sum of first 10 natural number using loop

Output

    Natural numbers ----

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Sum of first 10 natural numbers : 55
                    

Write a C++ program to print multiplication table of given number

Output

    Multiplication table of : 16
    16 X 0 = 0
    16 X 1 = 16
    16 X 2 = 32
    16 X 3 = 48
    16 X 4 = 64
    16 X 5 = 80
    16 X 6 = 96
    16 X 7 = 112
    16 X 8 = 128
    16 X 9 = 144
    16 X 10 = 160
                    

Write a C++ program to find the factorial value of any number entered through the keyboard

Output

    Enter a number to find its factorial : 5
    Factorial of 5 is : 120

    Enter a number to find its factorial : 16
    Factorial of 16 is : 2004189184
                    

Write a C++ program that prompts the user to input an integer and then outputs the number with the digits reversed order

Output

    Enter an integer to reverse it : 123456

    123456 after reversing : 654321
                    

Write a C++ program that reads a set of integers, and then prints the sum of the even and odd integers using loop

Output

    Enter number of Integers : 8
    Enter element 0 : 56
    Enter element 1 : 2
    Enter element 2 : 6
    Enter element 3 : 3
    Enter element 4 : 8
    Enter element 5 : 1
    Enter element 6 : 9
    Enter element 7 : 10
    
    Sum of even integers : 82
    Sum of odd integers : 13
                    

Write a C++ program to check whether the number is a prime number or not

Output

    Enter an integer : 3
    3 is a prime number

    Enter an integer : 45
    45 is not a prime number
                    

Write a C++ program to calculate HCF of Two given numbers using loop

Output

    Enter first number: 24
    Enter second number: 36
    HCF of 24 and 36 is: 12

                    

Write a C++ program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros

Output


    Enter a number : 45
    Do you want to enter another number? (y/n): y
    Enter a number : 0
    Do you want to enter another number? (y/n): y
    Enter a number : -8
    Do you want to enter another number? (y/n): y
    Enter a number : 0
    Do you want to enter another number? (y/n): y
    Enter a number : 12
    Do you want to enter another number? (y/n): y
    Enter a number : 9
    Do you want to enter another number? (y/n): n
    
    Positive Integers : 3
    Negative integers : 1
    Zeroes : 2
                    

Write a C++ program to enter the numbers till the user wants and at the end the program should display the largest and smallest numbers entered

Output

    Enter a number : 45
    Do you want to enter another number? (y/n): y
    Enter a number : 373
    Do you want to enter another number? (y/n): y
    Enter a number : 8
    Do you want to enter another number? (y/n): y
    Enter a number : 534
    Do you want to enter another number? (y/n): n
    
    Largest number entered is : 534
    Smallest number entered is : 8
                    

Write a C++ program to print out all Armstrong numbers between 1 to 600 using loop

Output

    Armstrong numbers : equal to the sum of cubes of its digits
    
    1
    64
    125
    153
    216
    370
    371
    407
    
    These are all armstrong numbers between 1 to 600
                    

Write a C++ program to count total number of notes in entered amount using loop

Output

    Enter the amount: 2684
    Notes count for 2684 is:
    2000: 1
    500: 1
    100: 1
    50: 1
    20: 1
    10: 1
    2: 2

                    

Write a C++ program to print Fibonacci series of n terms where n is input by user using loop

Output

    Enter terms of Fibonacci series : 15
    
    Fibonacci series upto 15 terms :
    0
    1
    1
    2
    3
    5
    8
    13
    21
    34
    55
    89
    144
    233
    377
                    

Write a C++ program to calculate the sum of following series where n is input by user

Output

    Enter first number: 12
    Enter second number: 18
    GCD of 12 and 18 is: 6
    LCM of 12 and 18 is: 36

                    

Write a C++ method to compute the average of three numbers

Output

    Enter number 1 : 45
    Enter number 2 : 12
    Enter number 3 : 50

    Average of 45 12 50 is : 35.6667
                    

Write a C++ method to find the smallest number among three numbers

Output

    Enter number 1 : 89
    Enter number 2 : 63
    Enter number 3 : 56

    The smallest number among 89 63 and 56 is : 56
                    

Write a C++ method to check whether an year entered by the user is a leap year or not

Output

    Enter the year : 2024
    2024 is a leap year

    Enter the year : 2089
    2089 is not a leap year
                    

Write a C++ program to accept a float value of number and return a rounded float value

Output

    Enter a float number : 2348.189664
    
    2348.19 After rounding off : 2348
                    

Write a C++ method to compute the sum of the digits in an integer

Output

    Enter a number : 798402
    
    The sum of digits in 0 is : 30
                    

Write a C++ method to calculate the area of a triangle

Output

    Enter the length of base of triangle in cm : 23
    
    Enter the height of triangle in cm : 18.5
    
    The area of rectangle of base 23and height 18cm is : 207cm²
                    

Write a C++ method to find the area of a pentagon

Output

    Enter length of side of Pentagon in cm : 5
    Enter length of apothem of Pentagon in cm : 9

    The area of pentagon of side 5cm is : 112.5cm²
                    

Write a C++ method to find number is even number or not

Output

    Enter a number : 58
    58 is an even number.
                    

Write a C++ method to check numbers is palindrome number or not

Output

    Enter a number : 65482
    
    65482 is not a palindrome.
                    

Write a C++ method to displays prime numbers between 1 to 20

Output

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

Write a C++ method to find GCD and LCM of Two Numbers

Output

    Enter the dividend: 564
    Enter the divisor: 85
    Result of integer division (rounded up): 7
                    

Write a C++ method to find factorial using recursion

Output

    Enter a number : 7
    
    Factorial of 7 is : 5040
                    

Write a C++ program to reverse an integer number

Output

    Enter a number to reverse it : 456789
    4201104 After reversing : 987654
                    

Write a C++ program to round a float number to specified decimals

Output

    Enter any decimal number to round off it to specified decimals : 52.5615489
    
    Enter decimal number upto which round off the given number : 3
    
    52.562 = 52.562 after rounding off upto 3 decimals : 52.562
                    

Write a C++ program to test if a double number is an integer

Output

    Enter a number : 2.65
    The number 2.65 is not an integer.
                    

Write a C++ program to round up the result of integer division

Output

    Enter the dividend: 565
    Enter the divisor: 5
    Result of rounding up the division: 113

                    

Write a C++ program to convert Roman number to an integer number

Output

    Enter roman number to convert it into an integer : VII
    Integer equivalent of VII is : 7
    
    
    Enter roman number to convert it into an integer : XIIVI
    Integer equivalent of XIIVI is : 18
                    

Write a C++ program to convert a float value to absolute value

Output

    Enter a number to get its absolute value : 5.2656
    Absolute value of 5.2656 is : 5
                    

Create a class entering the command line arguments from the user and show all the arguments as output.

Output

    Command Line Arguments:
                    

Program to Check Anagram

Output

    Enter String 1 : hello
    
    Enter String 2 : yellow
    hello and yellow are not anagram
                    

Program to Swapping Pair of Characters

Output

    Enter a string: jumping
    String with swapped pairs: ujpmnig

                    

Program to Check if a String contains only digits?

Output

    Enter a string: 56564
    The string contains only digits.
                    

Program to perform Deep Copy for String?

Output

    Original: Hello, world!
    Deep Copy: Hello, world! This is a deep copy.

                    

Program to remove all occurrences of a given character from input String?

Output

    Enter a string : shanaya
    Enter character to be removed from shanaya : a
    
    shanaya After removing a All occurences : shny
                    

Program to Add Characters to a String

Output

    Enter a string : hello
    Enter characters to be added to string : world
    helloworld After appending characters : helloworld
                    

Program to check whether a string is a Palindrome

Output

    Enter a string : abcba
    abcba is a palindrome

                    

Program to Convert Enum to String

Output

    Today is Wednesday
                    

Program to count number of words in a String?

Output

    nter a string: hello world
    Number of words: 2

                    

Program to count the total number of characters in a string

Output

    Enter a string: today is sunday
    Number of words in the string: 3

                    

Program to count the total number of punctuation characters exists in a String

Output

    Enter a string: today! is it a sunday?
    Total number of punctuation characters in the string: 2
 
                    

Program to count the total number of vowels and consonants in a string

Output

    Enter a string: hello world
    Total number of vowels in the string: 3
    Total number of consonants in the string: 7

                    

Program to determine whether a given string is palindrome

Output

    Enter a string: high
    The string is not a palindrome.

                    

Program to determine whether one string is a rotation of another

Output

    Enter the first string: fall
    Enter the second string: fail
    The second string is not a rotation of the first string.
                    

Program to divide a string in 'N' equal parts.

Output

    Enter a string: hello
    Enter the number of parts to divide the string into: 2
    Divided parts of the string:
    hel
    lo

                    

Program to find all subsets of a string

Output

    Enter a string: hello
    Subsets of the string:
    
    h
    e
    he
    l
    hl
    el
    hel
    l
    hl
    el
    hel
    ll
    hll
    ell
    hell
    o
    ho
    eo
    heo
    lo
    hlo
    elo
    helo
    lo
    hlo
    elo
    helo
    llo
    hllo
    ello
    hello

                    

Program to find all the permutations of a string

Output

    Enter a string: 12
    12
    21
                    

Program to find maximum and minimum occurring character in a string

Output

    Enter a string: hello world
    Maximum occurring character: l
    Minimum occurring character: r

                    

Program to find Reverse of the string Program to Check Anagram

Output

    Enter a string: hello world
    Reverse of the string: dlrow olleh
 
                    

Program to find the duplicate characters in a string

Output

    Enter a string: hello
    Duplicate characters in the string: l
 
                    

Program to find the duplicate words in a string

Output

    Enter a string: hello
    Duplicate words in the string: l
  
                    

Program to find the frequency of characters

Output

 
    Enter a string: hello
    Character frequencies in the string:
    'l': 2
    'o': 1
    'e': 1
    'h': 1
 
                    

Program to find the largest and smallest word in a string

Output

    Enter a string: it is hot today
    Smallest word: it
    Largest word: today

                    

Program to find the longest repeating sequence in a string

Output

    Enter a string: hello world
    Longest repeating sequence: ll
 
                    

Program to find the most repeated word in a text file

Output

    Enter the filename: output.txt
    Most repeated word in the file: database

                    

Program to find the number of the words in the given text file

Output

    Enter the filename: output.txt
    Number of words in the file: 7

                    

Program to Get a Character From the Given String

Output

    Enter a string: hello world
    Enter the position of the character you want to retrieve (0-based): 5
    Character at position 5:o
 
                    

Program to Insert a string into another string

Output

    Enter the original string: hello
    Enter the string to insert: world
    Enter the position to insert: 2
    Resultant string after insertion: heworldllo
 
                    

Program to Print a New Line in String (Each word in newline)

Output

    Enter a string: hello world
    hello
    world
                    

Program to Print even length words

Output

    Enter a string: hello world
    Even length words in the string:
                    

Program to print smallest and biggest possible palindrome word in a given string

Output

    Enter a string: hello world
    Smallest palindrome word: ll
    Largest palindrome word: ll

                    

Program to remove all the white spaces from a string

Output

    Enter a string: hello world
    String after removing white spaces: helloworld
 
                    

Program to replace lower-case characters with upper-case and vice-versa

Output

    Enter a string: hello world
    String after swapping case: HELLO WORLD

                    

Program to replace the spaces of a string with a specific character

Output

    Enter a string: hel lo o
    Enter the character to replace spaces with: #
    String after replacing spaces: hel#lo#o

                    

Program to separate the Individual Characters from a String

Output

    Enter a string: hello world
    Individual characters from the string:
    h
    e
    l
    l
    o
    
    w
    o
    r
    l
    d
                    

Program to Splitting into a number of sub-strings

Output

    Enter a string: hejasjdonailsneg ia ahigiwuhfiua difhai
    Enter the delimiter character: a
    Enter the number of substrings: 4
    Substrings:
    hej
    sjdon
    ilsneg i

                    

Program to swap two string variables without using third or temp variable.

Output

    Enter the first string: hello
    Enter the second string: world
    After swapping:
    First string: world
    Second string: hello

                    

Read two String user input and check if first contains second?

Output

    Enter the first string: hello
    Enter the second string: world
    The first string does not contain the second string.
 
                    

Reverse String Word by Word

Output

    Enter a string: hello world
    Reversed string: world hello

                    

Write a program to check if two Strings are created with same characters? Program to Check Anagram

Output

    Enter the first string: hello
    Enter the second string: oh
    The strings are not created with the same characters.

                    

Write a program to find out first non repeated character from input String?

Output

    Enter a string: hello
    The first non-repeated character is: h

                    

Write a C++ method to count all words in a string

Output

    Enter a string: hello world
    Number of words in the string: 2

                    

Write a C++ method to count all vowels in a string

Output

    Enter a string: shAnaya
    Number of vowels in the string: 3

                    

Write a C++ Program to Sort Names in an Alphabetical Order

Output

    Enter the number of names: 3
    Enter name 1: shanaya
    Enter name 2: gunjan
    Enter name 3: shruti
    
    Sorted names in alphabetical order:
    gunjan
    shanaya
    shruti
                    

Write a C++ method to count all the words in a string.

Output

    Enter a string: shanaya
    Number of words in the string: 1
  
                    

Write a C++ method to compute the future investment value at a given interest rate for a specified number of years.

Output

    Enter the present value of the investment: 50000
    Enter the annual interest rate (in percentage): 5
    Enter the number of years: 6
    The future value of the investment after 6 years is: 67004.8
                    

Write a C++ method to print characters between two characters (i.e. A to P).

Output

    Enter the start character: k
    Enter the end character: s
    Characters between k and s are: k l m n o p q r s
                    

Write a C++ method to check whether a string is a valid password.

Output

    Enter a password: Shanaya@2005
    Password is valid.
                    

Write a C++ method to display the current date and time.

Output

    Current date and time: 2024-4-6 7:30:48

                    

Write a C++ method that accepts three integers and returns true if one is the middle point between the other two integers, otherwise false

Output

    Enter three integers: 456 65 57
    One of the integers is the middle point between the other two.
                    

C++ Program to convert String to int

Output

    Enter a string representing an integer: 456
    Enter a string to convert into an integer : 456
                    

C++ Program to convert int to String

Output

    Enter integer to convert to string : 98

    98 After converting to string : 98
                    

C++ Program to convert String to long

Output

    Enter a string to convert to long: 541.15655
    
    Converted to long integer: 541
                    

C++ Program to convert long to String

Output

    Enter a long integer: 45558894
    Converted string: 45558894
                    

C++ Program to convert String to float

Output

   
    Enter a string representing a float : 16465.515
    Converted float: 16465.5
                    

C++ Program to convert float to String

Output

    Enter a float: 12321.56165
    Converted string: 12321.561523

                    

C++ Program to convert String to double

Output

    nter a string representing a double: 566565665
    Converted double: 5.66566e+008

                    

C++ Program to convert double to String

Output

    Enter a double: 2555616
    Converted string: 2555616.000000
                    

C++ Program to convert char to int

Output

    Enter a digit character : g
    Converted integer: 55
                    

C++ Program to convert int to char

Output

    Enter an integer (0-9): 117
    Converted character: Ñ
                    

C++ Program to convert Binary to Decimal

Output

    Enter a number to convert it into binary : 1001010101
    
    1001010101 in decimal format : 597
                    

C++ Program to convert Decimal to Binary

Output

    Enter a number to convert it into binary : 47
    
    47 in binary format 101111
                    

C++ Program to convert Hex to Decimal

Output

    Enter a hexadecimal number: 6c75a

    Decimal equivalent of 6c75a is: 1433090848
                    

C++ Program to convert Decimal to Hex

Output

    Enter a number to convert to Hexadecimal : 26546

    26546 After converting to Hexadecimal : 67b2
                    

C++ Program to convert Octal to Decimal

Output

    Enter an octal number : 213165
    213165 After converting to decimal : -653325840

                    

C++ Program to convert Decimal to Octal

Output

    Enter a number to convert to octal : 48690
    
    48690 After converting to octal : 137062
                    

Write a C++ method to find the smallest number among three numbers.

Output

    Enter number 1 : 302
    Enter number 2 : 46
    Enter number 3 : 2

    The smallest number among 302 46 and 2 is : 2
                    

Write a C++ method to compute the average of three numbers.

Output

    Enter number 1 : 56
    Enter number 2 : 40.5
    Enter number 3 : 429
    
    The average of 56 40.5 and 429 is : 175.167
                    

Write a C++ method to display the middle character of a string.

Output

    Enter a string to get its middle character : shanaya
    
    The middle character of string shanaya is : n
                    

Write a C++ method to find all twin prime numbers less than 100.

Output

    All twin prime numbers less than 100 :
    (3, 5)
    (5, 7)
    (11, 13)
    (17, 19)
    (29, 31)
    (41, 43)
    (59, 61)
    (71, 73)
                    

Write a C++ method to count the number of digits in an integer with the value 2. The integer may be assumed to be non-negative.

Output

    Enter a number to get number of digits : 54344
    digit 0 of 54344 : 4
    digit 1 of 54344 : 4
    digit 2 of 54344 : 3
    digit 3 of 54344 : 4
    digit 4 of 54344 : 5
    The number of digits in 54344 = 5
 
                    

Write a C++ method that accepts three integers and checks whether they are consecutive or not. Returns true or false.

Output

    Enter number 1 : 34
    Enter number 2 : 53
    Enter number 3 : 75
    
    34 53 and 75 are not consecutive numbers.

    Enter number 1 : 54
    Enter number 2 : 55
    Enter number 3 : 56
    
    54 55 and 56 are consecutive numbers.
                    

Write a C++ method that checks whether all the characters in a given string are vowels (a,e,i,o,u) or not. Return true if each character in the string is a vowel, otherwise return false.

Output

    Enter a string : shanaya
    shanaya do not contains all vowels

    Enter a string : aeiou
    aeiou contains all vowels
                    

Write a C++ program to create a class called "Person" with a name and age attribute. Create two instances of the "Person" class, set their attributes using the constructor, and print their name and age.

Output

    name of the person is :- rahul
    age of the person is:- 24
    name of the person is :- anjali
    age of the person is:- 21
 
                    

Write a C++ program to create a class called "Dog" with a name and breed attribute. Create two instances of the "Dog" class, set their attributes using the constructor and modify the attributes using the setter methods and print the updated values.

Output

    Initial values:
    Dog 1 - Name: Buddy, Breed: Labrador Retriever
    Dog 2 - Name: Max, Breed: German Shepherd
    
    Updated values:
    Dog 1 - Name: Charlie, Breed: Labrador Retriever
    Dog 2 - Name: Max, Breed: Golden Retriever

                    

Write a C++ program to create a class called "Rectangle" with width and height attributes. Calculate the area and perimeter of the rectangle.

Output

    enter the length of the rectangle :-
    5
    enter the breadth of the rectangle :-
    4
    area of the rectangle is :- 20
    perimeter of the reactangle is :- 18
    enter the length of the rectangle :-
    7
    enter the breadth of the rectangle :-
    3
    area of the rectangle is :- 21
    perimeter of the reactangle is :- 20

                    

Write a C++ program to create a class called "Circle" with a radius attribute. You can access and modify this attribute. Calculate the area and circumference of the circle.

Output

    enter the radius of the circle :-
    5
    area of the circle = 78.5398
    perimeter of the circle = 31.4159
    enter the radius of the circle :-
    7
    area of the circle = 153.938
    perimeter of the circle = 43.9823
    enter the radius of the circle :-
    3
    area of the circle = 28.2743
    perimeter of the circle = 18.8496

                    

Write a C++ program to create a class called "Book" with attributes for title, author, and ISBN, and methods to add and remove books from a collection.

Output

    Book added to collection.
    Book added to collection.
    Book added to collection.
    Book removed from collection.

                    

Write a C++ program to create a class called "Employee" with a name, job title, and salary attributes, and methods to calculate and update salary.

Output

    Employee Details:
    Name: John Doe
    Job Title: Software Engineer
    Monthly Salary: $5000
    Annual Salary: $60000
    Salary updated successfully.
    
    Updated Employee Details:
    Name: John Doe
    Job Title: Software Engineer
    Monthly Salary: $5500
    Annual Salary: $66000

                    

Write a C++ program to create a class called "Bank" with a collection of accounts and methods to add and remove accounts, and to deposit and withdraw money. Also define a class called "Account" to maintain account details of a particular customer.

Output

 
    Account added.
    Account added.
    Deposit of $500 successful.
    Withdrawal of $1000 successful.

                    

Write a C++ program to create a class called "TrafficLight" with attributes for color and duration, and methods to change the color and check for red or green.

Output

    Current color: red
    Current color: green
    Current color: red
    Current color: green
    Current color: red
    Current color: green
    ...

                    

Write a C++ program to create a class called "Employee" with a name, salary, and hire date attributes, and a method to calculate years of service.

Output

    Employee Details:
    Name: John Doe
    Salary: $5000
    Years of Service: 5

                    

Write a C++ program to create a class called "Student" with a name, grade, and courses attributes, and methods to add and remove courses.

Output

    Course added.
    Course added.
    Course added.
    Course removed.
    Student Details:
    Name: John Doe
    Grade: 10
    Courses: Math, History,

                    

Write a C++ program to create a class called "Library" with a collection of books and methods to add and remove books.

Output

    Book added to library.
    Book added to library.
    Book removed from library.

                    

Write a C++ program to create a class called "Airplane" with a flight number, destination, and departure time attributes, and methods to check flight status and delay.

Output

    Flight Details:
    Flight Number: ABC123
    Destination: New York
    Departure Time: Thu Jan 2 02:34:49 2024
    Flight Status: On time
    Flight delayed.
    Updated Flight Status: Delayed

                    

Write a C++ program to create a class called "Inventory" with a collection of products and methods to add and remove products, and to check for low inventory.

Output

    Product 'Product B' removed from inventory.

                    

Write a C++ program to create a class called "School" with attributes for students, teachers, and classes, and methods to add and remove students and teachers, and to create classes.

Output

    Student added to school.
    Student added to school.
    Teacher added to school.
    Teacher added to school.
    Student removed from school.
    Teacher removed from school.
    Class created.
 
                    

Write a C++ program to create a class called "MusicLibrary" with a collection of songs and methods to add and remove songs, and to play a random song.

Output

    Song 'Song A' by Artist A added to the library.
    Song 'Song B' by Artist B added to the library.
    Song 'Song C' by Artist C added to the library.
    Song 'Song B' removed from the library.
    Now playing: Song C by Artist C

                    

Write a C++ program to create a class called "Shape" with abstract methods for calculating area and perimeter, and subclasses for "Rectangle", "Circle", and "Triangle".

Output

    Rectangle:
    Area: 20
    Perimeter: 18
    
    Circle:
    Area: 28.2743
    Perimeter: 18.8496
    
    Triangle:
    Area: 6
    Perimeter: 12

                    

Write a C++ program to create a class called "Movie" with attributes for title, director, actors, and reviews, and methods for adding and retrieving reviews.

Output

    Review added for movie 'Toy Story'.
    Review added for movie 'Toy Story'.
    Reviews for movie 'Toy Story':
    - Great movie for kids!
    - I laughed so hard during this movie.

                    

Write a C++ program to create a class called "Restaurant" with attributes for menu items, prices, and ratings, and methods to add and remove items, and to calculate average rating.

Output

    Item added to the menu.
    Item added to the menu.
    Item added to the menu.
    Item removed from the menu.
    Average rating of the restaurant: 4.5

                    

Write a C++ program to create a class with methods to search for flights and hotels, and to book and cancel reservations.

Output

    Searching for flights to New York on 2024-04-15...
    Flight 'Flight123' booked successfully.
    Searching for hotels in London on 2024-05-20...
    Hotel 'Hotel456' booked successfully.
    Flight reservation for 'Flight123' canceled.
    Hotel reservation for 'Hotel456' canceled.

                    
Create a class showing an example of default constructor.

Output

    Default constructor called.
    Data: 0, 0, Default 
                    

Create a class showing an example of parameterized constructor.

Output

    Parameterized constructor called.
    Data: 10, 3.14, Hello

                    

Create a class showing an example of copy constructor.

Output

    Parameterized constructor called.
    Copy constructor called.
    Object 1:
    Data: 10, 3.14, Hello
    
    Object 2:
    Data: 10, 3.14, Hello
 
                    

Create a class entering the rollno, name and class of the student from user but rollno should be automatically generated as we enter the information of 10 students

Output

    Enter name of student 1: Alice
    Enter class of student 1: Grade 10
    Enter name of student 2: Bob
    Enter class of student 2: Grade 11
    Enter name of student 3: Charlie
    Enter class of student 3: Grade 9
    Enter name of student 4: David
    Enter class of student 4: Grade 10
    Enter name of student 5: Emily
    Enter class of student 5: Grade 11
    Enter name of student 6: Frank
    Enter class of student 6: Grade 9
    Enter name of student 7: Grace
    Enter class of student 7: Grade 10
    Enter name of student 8: Henry
    Enter class of student 8: Grade 11
    Enter name of student 9: Isabel
    Enter class of student 9: Grade 9
    Enter name of student 10: Jack
    Enter class of student 10: Grade 10
    
    Student 1 Information:
    Name: Alice
    Class: Grade 10
    
    Student 2 Information:
    Name: Bob
    Class: Grade 11
    
    Student 3 Information:
    Name: Charlie
    Class: Grade 9
    
    Student 4 Information:
    Name: David
    Class: Grade 10
    
    Student 5 Information:
    Name: Emily
    Class: Grade 11
    
    Student 6 Information:
    Name: Frank
    Class: Grade 9
    
    Student 7 Information:
    Name: Grace
    Class: Grade 10
    
    Student 8 Information:
    Name: Henry
    Class: Grade 11
    
    Student 9 Information:
    Name: Isabel
    Class: Grade 9
    
    Student 10 Information:
    Name: Jack
    Class: Grade 10

                    

Create a class showing the area of circle and rectangle by method overloading.

Output

    Area of circle with radius 5 is: 78.5
    Area of rectangle with length 4 and width 6 is: 24
 
                    

Write a C++ program to create a class called Person with private instance variables name, age. and country. Provide public getter and setter methods to access and modify these variables.

Output

    Name: John
    Age: 30
    Country: USA

                    

Write a C++ program to create a class called BankAccount with private instance variables accountNumber and balance. Provide public getter and setter methods to access and modify these variables.

Output

    Account Number: 123456789
    Balance: 1000

                    

Write a C++ program to create a class called Rectangle with private instance variables length and width. Provide public getter and setter methods to access and modify these variables.

Output

    Length: 5
    Width: 3

                    

Write a C++ program to create a class called Employee with private instance variables employee_id, employee_name, and employee_salary. Provide public getter and setter methods to access and modify the id and name variables, but provide a getter method for the salary variable that returns a formatted string.

Output

    Employee ID: 1001
    Employee Name: John Doe
    Employee Salary: $50000.00

                    

Write a C++ program to create a class called Circle with a private instance variable radius. Provide public getter and setter methods to access and modify the radius variable. However, provide two methods called calculateArea() and calculatePerimeter() that return the calculated area and perimeter based on the current radius value.

Output

    Radius of the circle: 5
    Area of the circle: 78.5
    Perimeter of the circle: 31.4

                    

Write a C++ program to create a class called Car with private instance variables company_name, model_name, year, and mileage. Provide public getter and setter methods to access and modify the company_name, model_name, and year variables. However, only provide a getter method for the mileage variable.

Output

    Company Name: Toyota
    Model Name: Camry
    Year: 2020
    Mileage: 15000.5

                    

Write a C++ program to create a class called Student with private instance variables student_id, student_name, and grades. Provide public getter and setter methods to access and modify the student_id and student_name variables. However, provide a method called addGrade() that allows adding a grade to the grades variable while performing additional validation.

Output

    Student ID: 1001
    Student Name: John Doe

                    

Define a class Complex to represent complex numbers. Overload the + operator to add two complex numbers.

Output

    Result of addition : 5 + 3i
                    

Create a class Fraction to represent fractions. Overload the + operator to add two fractions.

Output

    Result of addition: 5/6

                    

Define a class Matrix to represent matrices. Overload the * operator to multiply two matrices.

Output

    Result of multiplication :
    58 64
    139 154
                    

Implement a class String to represent strings. Overload the + operator to concatenate two strings.

Output

    Concatenated string: Hello, world!
                    

Define a class Date to represent dates. Overload the < operator to compare two dates.

Output

    Date 1 is less than Date 2
                    

Implement a class Money to represent money. Overload the + operator to add two amounts of money.

Output

    Total amount: $26.25

                    

Create a class Rectangle to represent rectangles. Overload the == operator to check if two rectangles are equal.

Output

    rect1 and rect2 are equal
    rect1 and rect3 are equal
                    

Define a class Time to represent time. Overload the << operator to display the time in HH:MM format.

Output

    Time: 10:30
                    

Program to copy all elements of one array into another array

Output

    Contents of the destination array:
    1 2 3 4 5

                    

Program to find the frequency of each element in the array

Output

    Frequency of each element in the array:
    4: 1
    1: 3
    2: 3
    3: 2
    5: 1
                    

Program to left rotate the elements of an array

Output

    Enter the number of positions to rotate left: 8
    Array after left rotation:
    4 5 1 2 3
                    

Program to print the duplicate elements of an array

Output

 
    Duplicate elements in the array: 7 2 4
                    

Program to print the elements of an array

Output

    Elements of the array:
    1 2 3 4 5
                    

Program to print the elements of an array in reverse order

Output

    Elements of the array in reverse order:
    5 4 3 2 1

                    

Program to print the elements of an array present on even position

Output

    Elements of the array at even positions:
    1 3 5 7 9

                    

Program to print the elements of an array present on odd position

Output

    Elements of the array at odd positions:
    2 4 6 8 10

                    

Program to print the largest element in an array

Output

    Largest element in the array: 50

                    

Program to print the smallest element in an array

Output

    Smallest element in the array: 10

                    

Program to print the number of elements present in an array

Output

    Number of elements in the array: 5

                    

Program to print the sum of all the items of the array

Output

    Sum of all elements in the array: 150
                    

Program to right rotate the elements of an array

Output

    Array after right rotation:
    1 2 3 4 5
                    

Program to sort the elements of an array in ascending order

Output

    Array sorted in ascending order:
    1 2 3 5 9
                    

Program to sort the elements of an array in descending order

Output

    Array sorted in descending order:
    9 5 3 2 1
                    

Program to Find 3rd Largest Number in an array

Output

    The 3rd largest number in the array is: 3
                    

Program to Find 2nd Largest Number in an array

Output

    The 2nd largest number in the array is: 5
                    

Program to Find Largest Number in an array

Output

    The largest number in the array is: 9
                    

C++ Program Find 2nd Smallest Number in an array

Output

    The 2nd smallest number in the array is: 2
                    

Program to Find Smallest Number in an array

Output

    The smallest number in the array is: 1
                    

Program to Remove Duplicate Element in an array

Output

    Array after removing duplicates:
    1 2 3 4 5 6 7
                    

Program to Print Odd and Even Numbers from an array

Output

    Odd numbers: 1 3 5 7 9
    Even numbers: 2 4 6 8 10
                    

Write a C++ program to swap the first and last elements of an array and create a new array

Output

    Original array: 1 2 3 4 5
    New array after swapping first and last elements: 5 2 3 4 1
                    

Write a C++ program to count the number of even and odd elements in a given array

Output

    Number of even elements: 5
    Number of odd elements: 5

                    

Write a C++ program to sum values of an array

Output

    Sum of values in the array: 15
                    

Write a C++ program to find the index of an array element

Output

    Index of 3 in the array: 2
                    

Write a C++ program to calculate the average value of array elements

Output

    Average value of array elements: 3
                    

Write a C++ program to test if an array contains a specific value

Output

    The array contains the value 3
                    

Write a C++ program to find the maximum and minimum value of an array

Output

    The array contains the value 3

                    

Write a C++ program to insert an element (specific position) into an array

Output

    Array after inserting 10 at position 2: 1 2 10 3 4 5
                    

Write a C++ program to reverse an array of integer values

Output

    Reversed array: 5 4 3 2 1
                    

Write a C++ program to find the common elements between two arrays

Output

    Common elements between the two arrays: 3 4 5

                    

Write a C++ program to find the duplicate values of an array of integer values

Output

    Duplicate values in the array: 1 2
                    

Write a C++ program to find second largest number from the array

Output

    The second largest number in the array is: 5
                    

Write a C++ program to find second lowest number from the array

Output

    The second lowest number in the array is: 2
                    

Write a C++ program to find the number of even and odd integers in a given array of integers

Output

    Number of even integers: 5
    Number of odd integers: 5
                    

Write a C++ program to get the difference between the largest and smallest values in an array of integers

Output

    Difference between the largest and smallest values: 8
                    

Write a C++ program to segregate all 0s on left side and all 1s on right side of a given array of 0s and 1s

Output

    Array after segregating 0s on left and 1s on right: 0 0 0 0 1 1 1 1
                    

Write a C++ program to cyclically rotate a given array clockwise by one

Output

    Array after rotating clockwise by one position: 5 1 2 3 4

                    

Write a C++ program to print all unique element in an array

Output

    Unique elements in the array: 5 1 2 3 4
                    

Write a C++ Program to Sort the Array in an Ascending Order

Output

    Sorted array in ascending order: 1 2 3 5 9
                    

Write a C++ Program to Sort the Array in an Descending Order

Output

    Sorted array in descending order: 9 5 3 2 1

                    

Write a C++ Program to Search Key Elements in an Array

Output

    Element 9 found at index 2

                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the number of rows: 3
    Enter the number of columns: 3
    Enter the elements of the matrix:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (0,2): 3
    Enter element at position (1,0): 4
    Enter element at position (1,1): 5
    Enter element at position (1,2): 6
    Enter element at position (2,0): 7
    Enter element at position (2,1): 8
    Enter element at position (2,2): 9
    Matrix:
    1 2 3
    4 5 6
    7 8 9

                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the number of rows for matrices A and B: 2
    Enter the number of columns for matrices A and B: 2
    Enter elements of matrix A:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (1,0): 3
    Enter element at position (1,1): 4
    Enter elements of matrix B:
    Enter element at position (0,0): 5
    Enter element at position (0,1): 6
    Enter element at position (1,0): 7
    Enter element at position (1,1): 8
    Matrix A:
    1 2
    3 4
    Matrix B:
    5 6
    7 8
    Resultant Matrix:
    6 8
    10 12

                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the number of rows for matrix A: 2
    Enter the number of columns for matrix A: 2
    Enter the number of rows for matrix B: 2
    Enter the number of columns for matrix B: 2
    Enter elements of matrix A:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (1,0): 3
    Enter element at position (1,1): 4
    Enter elements of matrix B:
    Enter element at position (0,0): 5
    Enter element at position (0,1): 6
    Enter element at position (1,0): 7
    Enter element at position (1,1): 8
    Matrix A:
    1 2
    3 4
    Matrix B:
    5 6
    7 8
    Resultant Matrix:
    19 22
    43 50
 
                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the number of rows for matrices A and B: 2
    Enter the number of columns for matrices A and B: 2
    Enter elements of matrix A:
    Enter element at position (0,0): 5
    Enter element at position (0,1): 4
    Enter element at position (1,0): 3
    Enter element at position (1,1): 2
    Enter elements of matrix B:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (1,0): 3
    Enter element at position (1,1): 4
    Matrix A:
    5 4
    3 2
    Matrix B:
    1 2
    3 4
    Resultant Matrix:
    4 2
    0 -2
 
                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the number of rows for matrices A and B: 2
    Enter the number of columns for matrices A and B: 2
    Enter elements of matrix A:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (1,0): 3
    Enter element at position (1,1): 4
    Enter elements of matrix B:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (1,0): 3
    Enter element at position (1,1): 4
    Matrices A and B are equal.

                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the size of the square matrix: 3
    Enter elements of the square matrix:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (0,2): 3
    Enter element at position (1,0): 4
    Enter element at position (1,1): 5
    Enter element at position (1,2): 6
    Enter element at position (2,0): 7
    Enter element at position (2,1): 8
    Enter element at position (2,2): 9
    Lower Triangular Matrix:
    1 0 0
    4 5 0
    7 8 9
 
                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the size of the square matrix: 3
    Enter elements of the square matrix:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (0,2): 3
    Enter element at position (1,0): 4
    Enter element at position (1,1): 5
    Enter element at position (1,2): 6
    Enter element at position (2,0): 7
    Enter element at position (2,1): 8
    Enter element at position (2,2): 9
    Upper Triangular Matrix:
    1 2 3
    0 5 6
    0 0 9

                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the number of rows for the matrix: 3
    Enter the number of columns for the matrix: 3
    Enter elements of the matrix:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (0,2): 3
    Enter element at position (1,0): 4
    Enter element at position (1,1): 5
    Enter element at position (1,2): 6
    Enter element at position (2,0): 7
    Enter element at position (2,1): 8
    Enter element at position (2,2): 9
    Frequency of odd numbers: 5
    Frequency of even numbers: 4
                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the number of rows for the matrix: 3
    Enter the number of columns for the matrix: 3
    Enter elements of the matrix:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (0,2): 3
    Enter element at position (1,0): 4
    Enter element at position (1,1): 5
    Enter element at position (1,2): 6
    Enter element at position (2,0): 7
    Enter element at position (2,1): 8
    Enter element at position (2,2): 9
    Sum of each row:
    Row 1: 6
    Row 2: 15
    Row 3: 24
    Sum of each column:
    Column 1: 12
    Column 2: 15
    Column 3: 18
 
                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the size of the square matrix: 3
    Enter elements of the square matrix:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 0
    Enter element at position (0,2): 0
    Enter element at position (1,0): 0
    Enter element at position (1,1): 1
    Enter element at position (1,2): 0
    Enter element at position (2,0): 0
    Enter element at position (2,1): 0
    Enter element at position (2,2): 1
    The given matrix is an identity matrix.

                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the number of rows for the matrix: 3
    Enter the number of columns for the matrix: 2
    Enter elements of the matrix:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 2
    Enter element at position (1,0): 3
    Enter element at position (1,1): 4
    Enter element at position (2,0): 5
    Enter element at position (2,1): 6
    Original Matrix:
    1 2
    3 4
    5 6
    Transposed Matrix:
    1 3 5
    2 4 6

                    

Enter the Matrix of rows and columns entered by the user and print in matrix format

Output

    Enter the number of rows for the matrix: 3
    Enter the number of columns for the matrix: 3
    Enter elements of the matrix:
    Enter element at position (0,0): 1
    Enter element at position (0,1): 0
    Enter element at position (0,2): 0
    Enter element at position (1,0): 0
    Enter element at position (1,1): 2
    Enter element at position (1,2): 0
    Enter element at position (2,0): 0
    Enter element at position (2,1): 0
    Enter element at position (2,2): 3
    Enter the threshold percentage for zero elements (0-100): 60
    The given matrix is not a sparse matrix.

                    

Write a C++ program to create a class called Animal with a method called makeSound(). Create a derived class called Cat that overrides the makeSound() method to bark.

Output

    Animal sound: Some generic sound...
    Cat sound: Meow!

                    

Write a C++ program to create a class called Vehicle with a method called drive(). Create a derived class called Car that overrides the drive() method to print "Repairing a car".

Output

    Vehicle status: Driving a vehicle...
    Car status: Repairing a car...

                    

Write a C++ program to create a class called Shape with a method called getArea(). Create a derived class called Rectangle that overrides the getArea() method to calculate the area of a rectangle.

Output

    Area of the rectangle: 15
                    

Write a C++ program to create a class called Employee with methods called work() and getSalary(). Create a derived class called HRManager that overrides the work() method and adds a new method called addEmployee().

Output

    Working as an HR manager...
    Added employee: John
    Added employee: Alice
    HR Manager's salary: $5000

                    

Write a C++ program to create a class known as "BankAccount" with methods called deposit() and withdraw(). Create a derived class called SavingsAccount that overrides the withdraw() method to prevent withdrawals if the account balance falls below one hundred.

Output

    Deposited $100. Current balance: $300
    Withdrawn $50. Current balance: $250
    Withdrawn $150. Current balance: $100

                    

Write a C++ program to create a class called Animal with a method named move(). Create a derived class called Cheetah that overrides the move() method to run.

Output

    Animal movement: Moving...
    Cheetah movement: Running like a cheetah!

                    

Write a C++ program to create a class known as Person with methods called getFirstName() and getLastName(). Create a derived class called Employee that adds a new method named getEmployeeId() and overrides the getLastName() method to include the employee's job title

Output

    Employee's full name: John Doe, Software Engineer
    Employee ID: E123

                    

Write a C++ program to create a class called Shape with methods called getPerimeter() and getArea(). Create a derived class called Circle that overrides the getPerimeter() and getArea() methods to calculate the area and perimeter of a circle.

Output

    Perimeter of the circle: 31.4159
    Area of the circle: 78.5398

                    

Write a C++ program to create a vehicle class hierarchy. The base class should be Vehicle, with derived classes Truck, Car and Motorcycle. Each derived class should have properties such as make, model, year, and fuel type. Implement methods for calculating fuel efficiency, distance traveled, and maximum speed.

Output

    Truck Fuel Efficiency: 500 miles
    Car Fuel Efficiency: 375 miles
    Motorcycle Fuel Efficiency: 200 miles

    Truck Distance Traveled in 2.5 hours: 1250 miles
    Car Distance Traveled in 2.5 hours: 937.5 miles
    Motorcycle Distance Traveled in 2.5 hours: 500 miles

    Truck Maximum Speed: 70 mph
    Car Maximum Speed: 120 mph
    Motorcycle Maximum Speed: 150 mph
                    

Write a C++ program that creates a class hierarchy for employees of a company. The base class should be Employee, with derived classes Manager, Developer, and Programmer. Each derived class should have properties such as name, address, salary, and job title. Implement methods for calculating bonuses, generating performance reports, and managing projects.

Output

    Bonus for John Doe (Manager): $500
    Bonus for Alice Smith (Developer): $200
    Bonus for Bob Johnson (Programmer): $315
    Performance report for John Doe (Manager):
    This manager has successfully completed the project assigned.
    Performance report for Alice Smith (Developer):
    This developer has completed coding tasks efficiently.
    Performance report for Bob Johnson (Programmer):
    This programmer has successfully completed programming tasks.
    John Doe is managing a new project.
    Alice Smith is not assigned to manage any projects.
    Bob Johnson is not assigned to manage any projects.
                    

Write a C++ program to create a new text file and write some text into it.

Output

    Text has been written to the file successfully.
                    

Write a C++ program to open an existing text file and display its contents on the console.

Output

    Hello, this is a text file created using C++.
    This is the second line of text.
    And here is the third line.
                    

Write a C++ program to count the number of lines in a text file.

Output

    Number of lines in the file: 3
                    

Write a C++ program to count the number of words in a text file.

Output

    Number of words in the file: 22
                    

Write a C++ program to copy the contents of one text file to another.

Output

    Contents copied successfully.
                    

Write a C++ program to find and replace a specific word in a text file.

Output

    Word replaced successfully.
                    

Write a C++ program to append new data to an existing text file.

Output

    Enter new data to append to the file (type 'exit' to stop): Hey how are you
    Data appended successfully.
                    

Write a C++ program to sort the lines of a text file in alphabetical order.

Output

    Lines sorted successfully.

                    

Write a C++ program to merge multiple text files into a single file.

Output

    Files merged successfully.

                    

Write a C++ program to split a large text file into smaller files of equal size.

Output

    File split successfully into 3 parts.
                    

Write a C++ program to search for a specific string in a text file and display its line number(s).

Output

    The string 'hello' is not found in the file.

                    

Write a C++ program to encrypt the contents of a text file using a simple encryption algorithm.

Output

    File encrypted successfully.

                    

Write a C++ program to decrypt the contents of a text file encrypted using the above algorithm.

Output

    File decrypted successfully.

                    

Write a C++ program to read a CSV file and display its contents in tabular form.

Output

    Name    |Age     |City |
    John    |25      |New York |
    Alice   |30      |Los Angeles |
    Bob     |35      |Chicago |

                    

Write a C++ program to calculate the average of numbers stored in a file.

Output

    Error: No valid numbers found in the file.

                    

Write a C++ program to store the information of 10 Students having roll no,name,marks,mobile no properties, get() and set() member functions as binary file with following options 1. Insert Record 2. Delete Record 3. Update Record (based on roll no) 4. Search Record (based on roll no) 5. Clone the file 6. Exit.

Output

    Options:
    1. Insert Record
    2. Delete Record
    3. Update Record
    4. Search Record
    5. Clone the file
    6. Exit
    Enter your choice:
                    

Write a C++ program to create an abstract class Animal with an abstract method called sound(). Create derived classes and Tiger that extend the Animal class and implement the sound() method to make a specific sound for each animal.

Output

    Sound of Lion: Lion Roars!
    Sound of Tiger: Tiger Growls!
                    

Write a C++ program to create an abstract class Animal with an abstract method called sound(). Create derived classes Lion and Tiger that extend the Animal class and implement the sound() method to make a specific sound for each animal.

Output

    Sound of Lion: Lion roars!
    Sound of Tiger: Tiger growls!
                    

Write a C++ program to create an abstract class Shape with abstract methods calculateArea() and calculatePerimeter(). Create derived classes Circle and Triangle that extend the Shape class and implement the respective methods to calculate the area and perimeter of each shape.

Output

    Circle:
    Area: 78.5398
    Perimeter: 31.4159
    
    Triangle:
    Area: 6
    Perimeter: 12

                    

Write a C++ program to create an abstract class BankAccount with abstract methods deposit() and withdraw(). Create derived classes: SavingsAccount and CurrentAccount that extend the BankAccount class and implement the respective methods to handle deposits and withdrawals for each account type.

Output

    Savings Account:
    Balance: 1000
    Balance: 500
    
    Current Account:
    Balance: 2000
    Balance: 1000
                    

Write a C++ program to create an abstract class Animal with abstract methods eat() and sleep(). Create derived classes Lion, Tiger, and Deer that extend the Animal class and implement the eat() and sleep() methods differently based on their specific behavior.

Output

    Lion:
    Lion eats meat.
    Lion sleeps in a cave.
    
    Tiger:
    Tiger eats meat.
    Tiger sleeps in a jungle.
    
    Deer:
    Deer eats grass.
    Deer sleeps under trees.
                    

Write a C++ program to create an abstract class Employee with abstract methods calculateSalary() and displayInfo(). Create derived classes Manager and Programmer that extend the Employee class and implement the respective methods to calculate salary and display information for each role.

Output

    Manager Information:
    Manager Name: John Doe
    Base Salary: 5000
    Bonus: 1500
    Total Salary: 6500
    
    Programmer Information:
    Programmer Name: Alice Smith
    Base Salary: 4000
    Number of Projects: 3
    Total Salary: 5500
                    

Write a C++ program to create an abstract class Shape3D with abstract methods calculateVolume() and calculateSurfaceArea(). Create derived classes Sphere and Cube that extend the Shape3D class and implement the respective methods to calculate the volume and surface area of each shape

Output

    Sphere:
    Volume: 523.599
    Surface Area: 314.159
    
    Cube:
    Volume: 27
    Surface Area: 54

                    

Write a C++ program to create an abstract class Vehicle with abstract methods startEngine() and stopEngine(). Create derived classes Car and Motorcycle that extend the Vehicle class and implement the respective methods to start and stop the engines for each vehicle type.

Output

    Car:
    Car engine started.
    Car engine stopped.
    
    Motorcycle:
    Motorcycle engine started.
    Motorcycle engine stopped.
                    

Write a C++ program to create an abstract class Person with abstract methods eat() and exercise(). Create derived classes Athlete and LazyPerson that extend the Person class and implement the respective methods to describe how each person eats and exercises.

Output

    Athlete:
    Athlete eats a balanced diet with high protein content.
    Athlete performs intense physical training regularly.
    
    Lazy Person:
    Lazy person eats junk food and snacks a lot.
    Lazy person avoids exercise and prefers sedentary lifestyle.
                    

Write a C++ program to create an abstract class Instrument with abstract methods play() and tune(). Create derived classes for Glockenspiel and Violin that extend the Instrument class and implement the respective methods to play and tune each instrument.

Output

    Glockenspiel:
    Glockenspiel makes tinkling sounds when played.
    Glockenspiel is tuned by adjusting the individual bars.
    
    Violin:
    Violin produces melodious sounds when played with a bow.
    Violin is tuned by adjusting the tension of the strings.
                    

Write a C++ program to create an abstract class Shape2D with abstract methods draw() and resize(). Create derived classes Rectangle and Circle that extend the Shape2D class and implement the respective methods to draw and resize each shape.

Output

    Rectangle:
    Drawing rectangle with width 5 and height 3
    Resized rectangle with width 7.5 and height 4.5
    
    Circle:
    Drawing circle with radius 4
    Resized circle with radius 3.2

                    

Write a C++ program to create an abstract class GeometricShape with abstract methods area() and perimeter(). Create derived classes Triangle and Square that extend the GeometricShape class and implement the respective methods to calculate the area and perimeter of each shape

Output

    Triangle:
    Area: 6
    Perimeter: 12
    
    Square:
    Area: 25
    Perimeter: 20
                    

Write a C++ program to create an abstract class Bird with abstract methods fly() and makeSound(). Create derived classes Eagle and Hawk that extend the Bird class and implement the respective methods to describe how each bird flies and makes a sound.

Output

    Eagle:
    Eagle soars high in the sky.
    Eagle makes a screeching sound.
    
    Hawk:
    Hawk flies swiftly with precision.
    Hawk emits a piercing cry.