Saturday, 24 December 2016

//PALINDROME: sequence that reads the same backwards as forwards.
//THIS PROGRAM HELP TO UNDERSTAND HOW PALINDROME WORKS.

#include<stdio.h>
#include<conio.h>
void main()
{
char one[10],two[10];
int cmp;
 printf("enter the string:");
scanf("%s",one);
strcpy(two,one); //strcpy use to copy one to two
strrev(one); //strrev is used to reverse the string
cmp=strcmp(one,two); /*strcmp used to compair the two string*/
if (cmp==0)
{
printf("entered string is palindrome");
    }
    else
    {
    printf("string is not palindrome");
}
getch();


}
//THIS IS MY FIRST AND EASIEST PROGRAM PROGRAM
//FACTORIAL OF SMALL NUMBER

#include<stdio.h>
#include<conio.h>
int main()
{
int fact=1,no,i;    //
printf("enter the no");
scanf("%d",&no);
for(i=no;i>=1;i--)
{
fact=fact*i;
}
printf("fact is %d",fact);
getch();


}

Thursday, 28 July 2016

CODING

BABYLONIA METHOD { ALGORITHM}

* An algorithm to find the square root of a number.


1) Give a number

2) Guess the square root of number.

3) Square your guess number and subtract it from original number.

4) If the absolute difference is less than an acceptable tolerance then you are done.

5) Else calculate a new guessed number guessed
 = (guessed +original/guessed) / 2

6) Go to step 3