Program to find frequency of characters in a string C++

Finding frequency of characters in a string C++ is like: Let the string is: I am Software engineer The Frequency if character ‘e’ in this String is: 4 Program to find frequency of characters in a string C++ CODE: #include <iostream> #include <cstring> using namespace std; int main() { char c[30],ch; int i,count=0; cout << […]

Read More

Program to convert String to Uppercase C++

Write a Program to convert string to Uppercase C++. PROGRAM: #include<iostream> using namespace std; int main( ) { char str[80]; cout<<“Enter a string:”; gets(str); for(int i=0;str[i]!=”;i++) str[i] = (str[i]>=’a’ && str[i]<=’z’)?(str[i]-32):str[i]; cout<<str; return 0; }   OUTPUT:

Read More

Program to convert string to lowercase c++

Write a Program to convert string to lowercase C++ without using library function tolower( ). PROGRAM: #include<iostream> using namespace std; int main( ) { char str[80]; cout<<“Enter a string:”; gets(str); for(int i=0;str[i]!=”;i++) str[i] = (str[i]>=’A’ && str[i]<=’Z’)?(str[i]+32):str[i]; cout<<str; return 0; }   OUTPUT:

Read More

Program to Reverse String C++

Write a Program to Reverse a String in C++. Reversing a number is quite easy task, see this to reverse a number Program to reverse a number To reverse a String we just exchange the first character with last character till we reach the mid of the string. Program to Reverse String C++: #include<iostream> using […]

Read More

Program to check whether String is palindrome or not C++

A simple program to check whether String is palindrome or not C++ PROGRAM: #include<iostream> using namespace std; int main( ) { int L,C; char str[80]; cout<<“nEnter a string: “; gets(str); for(L=0;str[L]!=”;L++); //To find length of the string for(C=0;(C<L/2) && (str[C]==str[L-C-1]);C++); if(C==L/2) cout<<“ntString is Palindrome”; else cout<<“ntNot a palindrome”; return 0; }   OUTPUT:

Read More

Write a Program to concatenate strings C++

A simple program to concatenate String c++ without using the library functions. Input 2 strings. Go to end of one string and add second after it. put NULL ‘’ at the end of the string.  Program to concatenate strings C++ #include<iostream> using namespace std; int main( ) { int l; char str1[80],str2[80]; cout<<“Enter first string :”; […]

Read More

Program to Find length of String C++

This is a simple program to find Length of a String in C++. Just traverse the string till NULL (‘’), increment the ‘i’ likewise. Program to Find length of a String C++ #include<iostream> using namespace std; int main( ) { int i; char str[80]; cout<<“Enter a string:”; gets(str); for(i=0;str[i]!=”;i++); cout<<“Lenght of string is :”<<i; return […]

Read More