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



C Program To Sort An Array Of Names In Alphabetical And Reverse Order

How to write a C Program To Sort An Array Of Names In Alphabetical And Reverse Order in C Programming Language ?


Solution For C Program :

/*C Program To Sort An Array Of Names In Alphabetical And Reverse Order.*/

#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
    {
    int i,j,k;
    char name[10][10],tname[10][10],temp[10];
    clrscr();
    printf("How many numbers you want to store:=");
    scanf("%d",&k);
    printf("Enter numbers for in an array:=");
       fflush(stdin);

    for(i=0;i<k;i++)
       {
       scanf("%s",name[i]);
       strcpy(tname[i],name[i]);
       }

    for(i=1;i<k;i++)
       {
       for(j=1;j<k;j++)
          {
          if(strcmpi(name[j],name[j-1])<0)
          {
          strcpy(temp,name[j-1]);
          strcpy(name[j-1],name[j]);
          strcpy(name[j],temp);
          }
          }
       }
    printf("The sorted names in alphabetical order [A to Z Format] are:\n");
    printf("\tOldlist\t\tNew list\n\n");
    for(i=0;i<k;i++)
        {
        printf("\t%s\t\t%s\n",tname[i],name[i]);
        }
    printf("\n\nThe sorted names in [Z to A Format] are:\n");
    for(i=k-1;i>=0;i--)
        {
        printf("\t%s\n",name[i]);
        }
    getch();
    }


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable