To perform string concatination & string comparison using operator overloading

Write a C++ program that overloads the + operator and relational operators (suitable) to perform the following operations:

  1. Concatenation of two strings.

2. Comparison of two strings.

 

 

Program to check whether the entered string is a substring of the main string or not.

Write a program that takes two input strings S1 and S2 and finds if S2 is a substring of S1 or not. If S2 is a substring of S1, the program should print the index at S1 at which there is a match. If S2 is not a substring of S1, the program should print -1. If S2 appears in S1 multiple times, print the first index in S1 at which the match occurred.

 

Code:

 

Create a class Rational Number (fractions) with mentioned capabilities

To create a class Rational Number (fractions) with the following capabilities:

  1. a) Create a constructor that prevents a 0 denominator in a fraction, reduces or simplifies fractions that are not in reduced form and avoids negative denominators.
  2. b) Overload the addition, subtraction, multiplication and division operators for this class.

c) Overload the relational and equality operators for this class.

 

 

Code:

 

Program to perform deposit/withdraw and other functions of a bank.

This program will take the input from user and withdraw/deposit the amount as per the liking of the user.

 

Code:

 

 

Program to find the number repeating maximum using classes

This is a program to find the number out of the given list of numbers which repeats the maximum no. of times.

We have predefined the numbers using array.

 

Code:

 

Program to create a saving account using class.

This is a basic c++ program to crate a saving account using class.

 

INPUT – time, rate of interest & balance

OUTPUT – Balance after that time.

Description:

We have to take the balance, rate of interest and time [in months] as input from user and display the balance which user will have after that time interval.

 

Code:

 

Program to represent a bank account using class [c++]

In this program we will take assumption that user has following details:

Account Number of user=001452
Balance of user=12555

Now using this information we will make a program to perform functions through which user can:

-> Deposit Amount

-> Withdraw Amount

->  Balance Inquiry

-> User Info.

 

Code:

 

All the code has been tested using codeblocks gcc compiler.

 

Program to display the number of prime numbers in the range entered by user and to display their sum.

This program will take a number as input from user and will display the number of prime numbers in the range starting from 0 to the number entered by user.

Also, it will be the sum of the prime numbers in that range.

We will be displaying program which is compatible with Dev C++.

You can download dev c++ from here

 

Program Code:

 

Continue reading “Program to display the number of prime numbers in the range entered by user and to display their sum.”

Program to find whether the number entered by user is prime or not.

This program checks whether a number is prime or not by dividing the entered number by all the numbers starting from 2 to the( entered number -1) and if the remainder is found to be 0 for any number then it will be displayed that the entered number is not a prime number.

But if none of the numbers have remainder as 0 then it will be displayed that the entered number is a prime number.

 

We will be displaying program which is compatible with Dev C++.

You can download dev c++ from here

 

Program Code:

 

Continue reading “Program to find whether the number entered by user is prime or not.”