## C++ Program to Find Highest and Lowest Element of a Matrix

Here you will get a C++ program to find highest or largest and lowest or smallest element of a matrix. #include<iostream> using namespace std; int main() { int m,n,a[10][10],i,j,high,low; cout<<“Enter no. of rows and coloumns:”; cin>>m>>n; cout<<“\nEnter matrix:\n”; for(i=0;i<m;++i) { for(j=0;j<n;++j) cin>>a[i][j]; } high=a[0][0]; low=a[0][0]; for(i=0;i<m;++i) { for(j=0;j<n;++j) { if(a[i][j]>high) high=a[i][j]; else if(a[i][j]<low) low=a[i][j]; } …

## C++ Program to Count Number of Words in String

Here you will get C++ program to count number of words in string. First we initialize a counter variable to 1. Now iterate through string and count all the spaces, for each space increase the value of counter. Finally print the counter variable, it contains the number of words. #include<iostream> #include<stdio.h> using namespace std; int …

## C++ Program to Concatenate Two Strings

Here you will get C++ program to concatenate two string without using library function. Below program will read two strings from user and then concatenate them to form third string. #include<iostream> using namespace std; int main() { char str1[30],str2[30],str3[60]; int i,j; cout<<“Enter first string:”; gets(str1); cout<<“\nEnter second string:”; gets(str2); for(i=0;str1[i]!=’\0′;++i) str3[i]=str1[i]; for(j=0;str2[j]!=’\0′;++j) str3[i+j]=str2[j]; str3[i+j]=’\0′; cout<<“\nThe …

## C++ Program to Reverse All the Strings Stored in an Array

Here you will get C++ program to reverse all the strings stored in an array. #include<iostream> #include<string.h> #include<stdio.h> using namespace std; int main() { char a[3][50]; int i,j,k,len; cout<<“Enter 3 strings:\n”; for(i=0;i<3;i++) { gets(a[i]); } cout<<“\nThe list of orignal strings:\n” ; for(i=0;i<3;i++) { cout<<a[i]<<“\n”; } cout<<“\nThe list of changed strings:\n”; for(i=0;i<3;i++) { len=strlen(a[i]); for(j=0,k=len-1;k>=0;j++,k–) { …

## C++ Program to Add Two Matrices

Here you will get a C++ program to find the addition of two matrices. We can add two matrices only if they have similar dimensions. For example: Matrix A: 3 72 5 Matrix B: 5 61 4 The addition of A and B is: 8 133 9 Let us see the code for matrix addition …

## C++ Program to Check String is Palindrome or not

Here you will get C++ program to check string is palindrome or not. A string is called palindrome if it is equal to its reverse. For example bob is string palindrome. #include<iostream> using namespace std; int main() { int i,j,len,flag=1; char a[20]; cout<<“Enter a string:”; cin>>a; for(len=0;a[len]!=’\0′;++len); for(i=0,j=len-1;i<len/2;++i,–j) { if(a[j]!=a[i]) flag=0; } if(flag==1) cout<<“\nThe string …

## C++ Program to Find Length of String

Here we will see various ways to find length of string in C++. We can do this in two ways, one is by using inbuilt functions such as length(), and size(), and another way is to find using a loop manually. Method 1: Using length() or size() Output: Length of the string is: 20Length of …

## C++ Program to Reverse a String

Here you will get C++ program to reverse a string. We will learn two ways to do this, using user-defined and inbuilt functions. The user is asked to enter a string and then the reverse of the string is displayed. For example: User Defined Function In this method, we will use a loop to reverse …