C language code for palindrome string

July 23, 2019


               
                                           
                                       A palindrome is a string, integer number or another sequence of characters that reads the same backward as forward, such as madam or racecar or the number 76567. If we read madam from the front or back side then the spelling and pronunciation are same i.e. nayan=nayan. The actual code for the palindrome string is as follows:   



C language code for Palindrome string:

#include <stdio.h>om

#include <string.h>

void main()

{

  char a[100], b[100];

  clrscr();

  printf("Enter a string to check if it is a palindrome:\n");

  gets(a); //to accept the string from user



  strcpy(b,a);  // Copying input string

  strrev(b);  // Reversing the string by inbuild function strrev()



  if (strcmp(a,b)==0)  /* Comparing input string using

  inbuild function strcmp() with the given reverse string*/



  printf("The string is a palindrome.\n");/* when if condition

  is satisfy or true */


  else

    printf("The string is not a palindrome.\n");/* when if condition

    is not satisfy or false */

  getch();

}

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

Output:

Enter a string to check if it is a palindrome:

asdfdsa

The string is a palindrome.
C language code for palindrome string C language code for palindrome string Reviewed by Amit Waghmare on July 23, 2019 Rating: 5

CPP code for Division of two numbers

July 07, 2019




Division OF TWO NUMBERS


SIMPLE CPP LANGUAGE CODE FOR DIVISION OF TWO NUMBERS:

#include<iostream.h>
#include<conio.h>
void main()
{
int a, b, c;//we take two integer value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to accept number
c=a/b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch();
}

And save with extension .cpp
for eg.
DIV.cpp// DIV is the name of the file and .cpp is extension of file.
           In the above example, we can divide integer numbers not fractional numbers. For example when output screen comes type two numbers like 9 and press enter then type next numbers like 3 then press enter the answer will be displayed on the output screen.
---------------------------------------------------------------------------------------
OUTPUT:
Enter the number: 9
                              3
Ans=3

            This code is for integer numbers if you want to divide fractional numbers then in above code small changes is there i.e.in the place of int type float. For Division of fractional numbers the code is as follow:

DIVISION OF TWO FRACTIONAL NUMBERS:
#include<iostream.h>
#include<conio.h>
void main()
{
float a, b, c;//we take two fractional value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to  accept number
c=a/b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch ();
}
OUTPUT:
Enter the number: 5.97
                              6.73
Ans=0.8870

           I hope you like my blog so if any queries are there then write in the comment box. I will solve it. Friends in the next blog I will teach you another program.

CPP code for Division of two numbers CPP code for Division of two numbers Reviewed by Amit Waghmare on July 07, 2019 Rating: 5

CPP code for Multiplication of two numbers

July 07, 2019



Multiplication OF TWO NUMBERS


SIMPLE CPP LANGUAGE CODE FOR MULTIPLICATION OF TWO NUMBERS:

#include<iostream.h>
#include<conio.h>
void main()
{int a, b, c;//we take two integer value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to accept number
c=a*b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch();
}

And save with extension .cpp
for eg.
MUL.cpp// MUL is the name of the file and .cpp is the extension of the file.
           In the above example, we can multiply integer numbers, not fractional numbers. For example when output screen comes type two numbers like 4 and press enter then type next numbers like 9 then press enter the answer will be displayed on the output screen.
---------------------------------------------------------------------------------------
OUTPUT:
Enter the number: 4
                              9
Ans=36

            This code is for integer numbers if you want to multiply fractional numbers then in above code small changes is there i.e.in the place of int type float. For Multiplication of fractional numbers the code is as follow:

MULTIPLICATION OF TWO FRACTIONAL NUMBERS:
#include<iostream.h>
#include<conio.h>
void main()
{flaot a, b, c;//we take two fractional value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to  accept number
c=a*b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch ();
}
OUTPUT:
Enter the number: 4.5
                              6.7
Ans=30.15

           I hope you like my blog so if any queries are there then write in the comment box. I will solve it. Friends in the next blog I will teach you another program.

CPP code for Multiplication of two numbers CPP code for Multiplication of two numbers Reviewed by Amit Waghmare on July 07, 2019 Rating: 5

CPP code for Subtraction of two numbers

July 07, 2019


Subtraction OF TWO NUMBERS


SIMPLE CPP LANGUAGE CODE FOR SUBTRACTION OF TWO NUMBERS:

#include<iostream.h>
#include<conio.h>
void main()
{int a, b, c;//we take two integer value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to accept number
c=a-b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch();
}

And save with extension .cpp
for eg.
subtract.cpp// subtract is the name of the file and .cpp is extension of file.
           In the above example, we can add integer numbers not fractional numbers. For example when output screen comes type two numbers like 45 and press enter then type next numbers like 60 then press enter the answer will be displayed on the output screen.
---------------------------------------------------------------------------------------
OUTPUT:
Enter the number: 45
                              60
Ans=105

            This code is for integer numbers if you want to add fractional numbers then in above code small changes is there i.e.in the place of int type float. For subtraction of fractional numbers the code is as follow:

SUBTRACTION OF TWO FRACTIONAL NUMBERS:
#include<iostream.h>
#include<conio.h>
void main()
{flaot a, b, c;//we take two fractional value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to  accept number
c=a-b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch ();
}
---------------------------------------------------------------------------------------
OUTPUT:
Enter the number: 4.5
                              6.7
Ans=11.2


     In the previous blog, I was say that many types of comment is there in that other type is
/*        comment         */.This is used to give the multiline comments for example.
cout<<"Ans="<< c;/*use to perform operation and display answer*/

           I hope you like my blog so if any queries are there then write in the comment box. I will solve it. Friends in the next blog I will teach you another program.

CPP code for Subtraction of two numbers CPP code for Subtraction of two numbers Reviewed by Amit Waghmare on July 07, 2019 Rating: 5

CPP code for Addition of two numbers

July 03, 2019


ADDITION OF TWO NUMBERS


SIMPLE CPP LANGUAGE CODE FOR ADDITION OF TWO NUMBERS:

#include<iostream.h>
#include<conio.h>
void main()
{int a, b, c;//we take two integer value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to accept number
c=a+b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch();
}

And save with extension .cpp
for eg.
add.cpp//add is the name of the file and .cpp is extension of file.
           In the above example, we can add integer numbers not fractional numbers. for example when the output screen comes type two numbers like 2 and press enter then type next numbers like 6 then press enter the answer will be displayed on the output screen.
            This code is for integer numbers, if we want to add fractional numbers then in above code small changes is there i.e.in the place of int type float.For addition of fractional numbers the code is as follow:

ADDITION OF TWO FRACTIONAL NUMBERS:
#include<iostream.h>
#include<conio.h>
void main()
{flaot a, b, c;//we take two fractional value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to  accept number
c=a+b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch ();
}

     In the previous blog, I said that many types of comment is there in that other type is
/*        comment         */  .This is used to give the multiline comments for example.
cout<<"Ans="<< c;/*use to perform operation and display answer*/

           I hope you like my blog so if any queries are there then write in the comment box. I will solve it. Friends in the next blog I will teach you another program.
CPP code for Addition of two numbers CPP code for Addition of two numbers Reviewed by Amit Waghmare on July 03, 2019 Rating: 5