Sunday, March 17, 2013

C++ program to concatenate strings

CONCATENATION OF TWO STRINGS USING C++ PROGRAM

# include < iostream>
# include < string >
using namespace std;
int main()

{
char str1[50], str2 [35];
cout << "Enter string str1;";
cin >> str1;
cout << "Enter string str2:";
cin >> str2;
strcat(str1,str2);
cout << "strcat (str1, str2 ) : "<< str1;

    system("pause");
return 0;
}


---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

C++ program to convert a string into upper-case or lower-case

Write a C++ program to convert the string from upper case to lower case

# include < iostream>
# include < string>
using namespace std;

int main()
{
char str1 [30], temp[30];
cout < < "Enter the string:";
cin > > str1;
strcpy ( temp, str1);
cout < < "strupr ( temp ) : " < < strupr (temp) < < end1;
cout < < "strlwr (temp) : " < < strlwr ( temp) < < end1;
system("pause");

return 0;
}

 ---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

C++ program to find prime number

C++ program code to find numbers

#include<iostream>
#include<iomanip>
int main(){
    int num,i,count;
 
    for(num = 1;num<=100;num++){
         count = 0;
         for(i=2;i<=num/2;i++){
             if(num%i==0){
                 count++;
                 break;
             }
        }
       
         if(count==0 && num!= 1)
             cout <<  num  << setw(3);
    }
 
   return 0;
}

 

 ---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

C++ program to find Armstrong number

C++ Program to Check given number is Armstrong number or not


#include<iostream>
#include<iomanip>
int main(){
    int num,r,sum,temp;
    for(num=1;num<=500;num++){
         temp=num;
         sum = 0;
         while(temp!=0){
             r=temp%10;
             temp=temp/10;
             sum=sum+(r*r*r);
         }
         if(sum==num)
             cout << num << setw(2);
    }
    return 0;
}

 

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

C++ program to find prime numbers in a given range

Write a C++ program to print all the prime numbers with in the given range



#include<iostream>
#include<iomanip>
using namespace std;

int main(){
    int num,i,count,n;
    cout << "Enter max range: ";
    cin >> n;
    for(num = 1;num<=n;num++){
         count = 0;
         for(i=2;i<=num/2;i++){
             if(num%i==0){
                 count++;
                 break;
             }
        }
       
         if(count==0 && num!= 1)
              cout << num << setw(3);
    }
 system("pause");
   return 0;
}


C++ Tutorial | Learn C++ programming



---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------



Program in C++ to find the prime number in given range
Write a C++ program to find prime numbers between 1 to 100
Prime numbers in a range - C++
Program to find the prime numbers between a given range
Write a program to print all the prime numbers with in the given range
C++ program to find prime numbers between two numbers
C++ program to find sum of prime numbers
C++ Program to Find Prime Numbers in a given Range

C++ Program to Find Perfect Number

C++ program to check whether a number is not a perfect number or not


#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  int n,i=1,sum=0;
  cout<<"Enter a number: ";
  cin >> n;
  while(i<n){
         if(n%i==0)
               sum=sum+i;
              i++;
  }
  if(sum==n)
         cout << i  <<  " is a perfect number";
  else
         cout << i << " is not a perfect number";
  system("pause");
  return 0;
}

C++ PROGRAM TO CHECK WHETHER A NUMBER IS A PERFECT NUMBER





---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------



Computing whether is a perfect number - C++
c++ - deciding if a number is perfect or prime
Find out the perfect number using c++ program
C++ Program to Find Perfect Number
C++ program to check if no. is perfect number or not
Program to Find the Given Number is Perfect Number or not in C

C++ program to convert decimal number into binary


Program to convert decimal to binary in C++



/* 
program : Decimal to binary. 
description : to convert decimal number between 0 to 255 to binary  */
# include <iostream>
#include <math.h>
using namespace std ;
int main()
{
unsigned short int x=0,b=128 ,z=0,a=8 ;
cout<<"please enter the number between 0 and 255 \n";
cin >> x;
if (x>255)
cout<<" out of range ";
else
{
cout << x <<" converted to binary number :" ; 
 while (a!=0)
 {
  z=x&b ;
  if (z==128)
  cout << "1" ;
  else
  cout << "0";
  x=(x << 1);
  a-- ;
}
}
cout<<"\n";
system("pause");
return 0 ;
}




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

C++ Program for Decimal to Hexadecimal Conversion

Convert decimal to hexadecimal (C++)



/* program : Decimal to hexadecimal. 
description : to convert decimal number between 0 to 255 to hexadecimal  */

#include <iostream>
using namespace std;

int main(void)
{
int mynum;
cout << "\nEnter a number: ";
cin >> mynum;
cout.unsetf(ios::dec);
cout.setf(ios::hex | ios::showbase);
cout << "In hex: " << mynum;
cout.unsetf(ios::hex);
cout.setf(ios::oct);
cout << "\nIn Octal: " << mynum;
cout.unsetf(ios::oct | ios::showbase);
cout.setf(ios::dec);
system("pause");
return 0;
}


---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ