Translate

Ad-Horizontal

Search This Blog

Friday 30 November 2018

How to write a C++ program (Turbo C++) to input two numbers and swap their values without using any third/other variable than variables used to assign the two numbers, using multiplication and division only.

We are gonna see how to write a C++ program (Turbo C++) to input Two Numbers and Swap their values without using any third/other variable than variables used to assign the two numbers, using Multiplication and Division only.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate result, users may replace "int" and "float" with "long" and "double" respectively.




The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long a=0,b=0;
cout<<"Enter the values of the First number(A) : "<<"\n";
cin>>a;
cout<<"Enter the values of the Second number(B) : "<<"\n";
cin>>b;
a=a*b;
b=a/b;
a=a/b;
cout<<"A ="<<a<<"\n";
cout<<"B ="<<b<<"\n";
getch();
}


Program:






Code







Output:



Result



Result













Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

How to write a C++ program (Turbo C++) to input two numbers and swap their values without using any third/other variable than variables used to assign the two numbers, using addition and subtraction only.

We are gonna see how to write a C++ program (Turbo C++) to input Two Numbers and Swap their values without using any third/other variable than variables used to assign the two numbers, using Addition and Subtraction only.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate result, users may replace "int" and "float" with "long" and "double" respectively.




The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long a=0,b=0;
cout<<"Enter the values of the First number(A) : "<<"\n";
cin>>a;
cout<<"Enter the values of the Second number(B) : "<<"\n";
cin>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"A ="<<a<<"\n";
cout<<"B ="<<b<<"\n";
getch();
}


Program:





Code








Output:




Result



Result








Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

Wednesday 28 November 2018

How to write a C++ program (Turbo C++) to input the Radius of a Circle and find out and display the Area and Circumference.

We are gonna see how to write a C++ program (Turbo C++) to input the Radius of a Circle and find out and display the Area and Circumference.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate result, users may replace "int" and "float" with "long" and "double" respectively.




The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double rad=0,cir=0,area=0,pi=3.14;
cout<<"Enter the measure of the Radius of the Circle:"<<"\n";
cin>>rad;
cir=2*pi*rad;
area=pi*rad**rad;
cout<<"The Circumference of the Circle : "<<cir<<"\n";
cout<<"The Area of the Circle : "<<area<<"\n";
getch();
}


Program:





Code








Output:




Result








Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

Sunday 25 November 2018

How to write a C++ program (Turbo C++) to input the side/sides of a Square and find out and display the Area and Perimeter.

We are gonna see how to write a C++ program (Turbo C++) to input the Side/Sides of a Square and find out and display the Area and Perimeter.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.




The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double side=0,peri=0,area=0;
cout<<"Enter the measure of the side/sides of the Square:"<<"\n";
cin>>side;
peri=4*side;
area=side*side;
cout<<"The Perimeter of the Square : "<<peri<<"\n";
cout<<"The Area of the Square : "<<area<<"\n";
getch();
}


Program:





Code








Output:




Result








Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

Thursday 22 November 2018

How to write a C++ program (Turbo C++) to input the Length and the Breadth of a Rectangle and find out and display the Area and Perimeter.

We are gonna see how to write a C++ program (Turbo C++) to input the Length and the Breadth of a Rectangle and find out and display the Area and Perimeter.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.




The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double len=0,bre=0,peri=0,area=0;
cout<<"Enter the Length of the Rectangle:"<<"\n";
cin>>len;
cout<<"Enter the Breadth of the Rectangle:"<<"\n";
cin>>bre;
peri=2*(len+bre);
area=len*bre;
cout<<"The Perimeter of the Rectangle : "<<peri<<"\n";
cout<<"The Area of the Rectangle : "<<area<<"\n";
getch();
}


Program:





Code








Output:




Output








Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

Sunday 18 November 2018

How to write a C++ program (Turbo C++) to find/calculate and display the factorial of the numbers from 1 to n (a user input number).

We are gonna see how to write a C++ program (Turbo C++)  to find/calculate and display the factorial of the numbers from 1 to n (a user input number).



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.




The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long lim=0,a=0,n=0,fact=1;
cout<<"Enter the limite:"<<"\n";
cin>>lim;
for(n=1;n<=lim;n++)
{
for(a=1;a<=n;a++)
{
fact=fact*a;
}
cout<<"The factorial of the Number,("<<n<<") is = "<<fact<<"\n";
fact=1;
}
getch();
}


Program:











Output:














Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

Wednesday 14 November 2018

How to write a C++ program (Turbo C++) to input a number and find out and display the sum of digits of that number.

We are gonna see how to write a C++ program (Turbo C++)  to input a number and find out and display the sum of digits of that number.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.




The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long num=0,n=0,sum=0,d=0;
cout<<"Enter the Number:"<<"\n";
cin>>num;
n=num;
while(n!=0)
{
d=n%10;
sum=sum+d;
n=n/10;
}
cout<<"The Sum of the digits of the number,("<<num<<") is = "<<sum<<"\n";
getch();
}


Program:












Output:












Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

How to write a C++ program (Turbo C++) to input a number and count the number of digits its contain.

We are gonna see how to write a C++ program (Turbo C++)  to input a number and count the number of digits its contain.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.




The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long num=0,n=0,count=0;
cout<<"Enter the number:"<<"\n";
cin>>num;
n=num;
while(n!=0)
{
count=count+1;
n=n/10;
}
cout<<"No.of Digits in the number,("<<num<<") is = "<<count<<"\n";
getch();
}



Program:











Output:


















Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

Thursday 8 November 2018

How to write a C++ program (Turbo C++) to input a number and check whether that number entered by the user is a Spy Number or not.

We are gonna see how to write a C++ program (Turbo C++)  to input a number and check whether that number entered by the user is a Spy Number or not.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.


Spy Number (Sum and Products of Digits are same) : A number is said to be a Spy number if the sum of all the digits is equal to the product of all digits.


The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long num=0,n=0,d=0,sum=0,pro=1;
cout<<"Enter the number, which to be checked:"<<"\n";
cin>>num
n=num;
while(n!=0)
{
d=n%10;
sum=sum+d;
pro=pro*d;
n=n/10;
}
if(sum==pro)
cout<<"The number,("<<num<<") is a Spy Number."<<"\n";
else
cout<<"The number,("<<num<<") is not a Spy number."<<"\n";
getch();
}



Program:















Output:



























Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

How to write a C++ program (Turbo C++) to input a number and check whether that number entered by the user is a Neon Number or not.

We are gonna see how to write a C++ program (Turbo C++)  to input a number and check whether that number entered by the user is a Neon Number or not.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.


neon number is a number in which the sum of digits of square of the number is equal to the number.


The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long num=0,num2=0,n2=0,d=0,sum=0;
cout<<"Enter the number, which to be checked:"<<"\n";
cin>>num
num2=num*num;
n2=num2;
while(n2!=0)
{
d=n2%10;
sum=sum+d;
n2=n2/10;
}
if(num==sum)
cout<<"The number,("<<num<<") is a Neon Number."<<"\n";
else
cout<<"The number,("<<num<<") is not a Neon number."<<"\n";
getch();
}



Program:















Output:




















Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

How to write a C++ program (Turbo C++) to input a number and check whether that number entered by the user is a Special Number or not.

We are gonna see how to write a C++ program (Turbo C++)  to input a number and check whether that number entered by the user is a Special Number or not.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.


special number is a number such that when the sum of the digits of the number is added to the product of its digits, the result is equal to the original number.


The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long num=0,n=0,d=0,sum=0,pro=1;
cout<<"Enter the number, which to be checked:"<<"\n";
cin>>num
n=num;
while(n!=0)
{
d=n%10;
sum=sum+d;
pro=pro*d;
n=n/10;
}
sum=sum+pro;
if(sum==num)
cout<<"The number,("<<num<<") is a Special Number."<<"\n";
else
cout<<"The number,("<<num<<") is not a Special number."<<"\n";
getch();
}



Program:















Output:













Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

How to write a C++ program (Turbo C++) to input a number and check whether that number entered by the user is a Strong/Peterson/Krishnamurthy Number or not.

We are gonna see how to write a C++ program (Turbo C++)  to input a number and check whether that number entered by the user is a Strong/Peterson/Krishnamurthy Number or not.



The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.


Strong numbers are the numbers whose sum of factorial of digits is equal to the original number. 


The code are as follows:

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long num=0,n=0,fact=1,d=0,sum=0,a=0;
cout<<"Enter the Number, which to be checked:"<<"\n";
cin>>num;
n=num;
while(n!=0)
{
d=n%10;
for(a=1;a<=d;a++)
{
fact=fact*a;
}
sum=sum+fact;
n=n/10;
fact=1;
}
if(sum==num)
cout<<"The Number,("<<num<<")  is a Strong/Peterson/Krishnamurthy Number."<<"\n";
else
cout<<"The Number,("<<num<<")  is not a Strong/Peterson/Krishnamurthy Number."<<"\n";
getch();
}



Program:
















Output:




















Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.

How to write a C++ program (Turbo C++) to input a number and find its Factorial.

We are gonna see how to write a C++ program (Turbo C++) to input a number and find its Factorial.


The following codes have been run and compiled in C++(Turbo C++).

The writing in the right-hand side of this "//" in the codes are called comments of the code. They are not a necessary part of the codes and can be omitted in the codes. They are just mentioned so as to tell you the use/purpose of writing the left-hand side of the "//" or the codes.   In some special cases depending upon the Fond & Size of the text on your device the comments may entered the right hand-side of the "//"(next line) and come in between the main codes. so as to, make it easier for you to understand/distinguish the comments from the main codes; we have written the main code and comments in different sizes.
Example: Main codes: "  #include<iostream.h>  "
                 Comments: "   //It is a header file and used to call the input-output classes(Pre-defined library in C++).  " .


The Variables are user initialized with zero, so that they won't store any garbage value and hamper the final output of the program.

For more accurate, users may replace "int" and "float" with "long" and "double" respectively.


Factorial of a number is the product of all integers less than or equal to that number.


The code are as follows:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long num=0,fact=1,n=0;
cout<<"Enter the Number:"<<"\n";
cin>>num;
for(n=1;n<=num,n++)
{
fact=fact*n;
}
cout<<"The Factorial of the number,("<<num<<") is = "<<fact<<"\n";
getch();
}




Program:











Output:

















Hope that  the Blog have helped you in your work. 


Do visit again to see more Coding related blogs.