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 Check String is Palindrome or not Read More »

Convert Binary to Decimal in C++

Here you will learn how to convert binary to decimal in C++. We can convert a binary number into decimals in the following way. Also Read: Convert Decimal to Binary in C++ C++ Program to Convert Binary to Decimal Output: Enter any Binary number:111The Decimal conversion of 111 is 7

Convert Decimal to Binary in C++

Here you will get the program to convert a number from decimal to binary in C++. How to convert decimal numbers to binary? This program can only convert nondecimal numbers. Also Read: Convert Binary to Decimal in C++ C++ Program to Convert Decimal to Binary Output: Enter a number:5The binary conversion of 5 is 101

C++ Program to Print First 10 Prime Numbers

Here is the C++ program to print first 10 prime numbers. #include<iostream> using namespace std; int main() { int i,j,count=1,b=0; cout<<“First Ten Prime Numbers Are\n”<<“2”; for(i=3;i>0;++i) { for(j=2;j<=i/2;++j) { if(i%j==0){ b=1; break; } } if(b==0) { cout<<“\n”<<i; count++; } b=0; if(count==10) break; } return 0; } Output First Ten Prime Numbers Are 2 3 5 …

C++ Program to Print First 10 Prime Numbers Read More »