Showing posts with label Reverse. Show all posts
Showing posts with label Reverse. Show all posts

C Program to Reverse a Word

How to write a C Program to Reverse a Word in C Programming Language ?

This program reverse a word.

Solution For C Program:

C Program Array Example: Reverse

How to write a C Program Array Example: Reverse in C Programming Language ?


Solution For C Program :

C Program To Find Reverse Of Any Digit Number

How to write a C Program To Find Reverse Of Any Digit Number in C Programming Language ?

Solution For C Program :

/*C Program To Find Reverse Of Any Digit Number.*/

/*It works good up to 9-digits.*/
#include<stdio.h>
#include<conio.h>
void main()
{
long int num,rem,rev=0,num1;
clrscr();
printf("Enter any digit number for reverse===>");
scanf("%ld",&num);
num1=num;
while(num1>0)
{
rem=num1%10;
num1/=10;
rev=rev*10+rem;
}
printf("Reverse of %ld is===>%ld",num,rev);
getch();
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program To Find The Length, Reverse Of A String And To Check It Is Palindrome or Not

How to write a C Program To Find The Length, Reverse Of A String And To Check It Is Palindrome or Not in C Programming Language ?


Solution For C Program :

/*C Program To Find The Length, Reverse Of A String And To Check It Is Palindrome or Not.*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,length=0,flag;
char str[10],rev[10];
clrscr();
printf("Enter the string==>");
scanf("%s",str);
for(i=0;str[i]!='\0';i++)
{
length++;
}
printf("\nLength of %s is ==>%d\n",str,length);
length--;
for(i=0;length>=0;i++)
{
 rev[i]=str[length];
 length--;
}
rev[i]='\0';
printf("\nReverse of %s is ==>%s\n",str,rev);

 length++;
for(i=0;rev[i]!='\0';i++)
{
length++;
}
printf("\nLength of %s is ==>%d\n",rev,length);

for(i=0;str[i]!='\0'||rev[i]!='\0';i++)
{
if(str[i]!=rev[i])
    {
    flag=1;
    break;
    }
}
if(flag==1)
printf("\nString is not polyndrom");
else
printf("\nString is polyndrom");
getch();
}

C Program To Reverse A Number

How to write a C Program To Reverse A Number in C Programming Language ?


Solution For C Program :

/*C Program To Reverse A Number.*/


#include<stdio.h>
#include<conio.h>
digit(int);
void main()
{
int num,f;
clrscr();
printf("Enter the any digit number==>");
scanf("%d",&num);
f=digit(num);
printf("\nSum of %d is==> %d",num,f);
getch();
}
digit(int k)
{
int sum=0;
if(k>0)
{
sum=k%10+digit(k/10);//recursion function call
}
return (sum);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable



C Program To Reverse The String Using Pointer

How to write a C Program To Reverse The String Using Pointer in C Programming Language ?


Solution For C Program :

/*C Program To Reverse The String Using Pointer.*/


#include<stdio.h>
#include<conio.h>
void reverse(char *);
void main()
{
clrscr();
  char st[10];
  gets(st);
  printf("reverse=");
  reverse(st);
  printf("\noriginal data=%s",st);
  getch();
}
void reverse(char *s)
{
  char c;
  if (*s==NULL)
  {
     return;
  }
  c=*s;
  s++;
  reverse(s);
  printf("%c",c);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable