Write a program to reverse the given string without using functions

Source Code

#include<stdio.h>
#include<conio.h>
int main (int argc, char *argv[])
{
  clrscr();
  char str[100];
  char t;
  int l=0;
  printf("\Enter the String:");
  gets(str);
  while(str[l]!='\0')
  {
    l++;
  }
  l--;
  for(int i=0;i<=(l/2);i++)
  {
    t=str[i];
    str[i]=str[l-i];
    str[l-i]=t;
  }
  printf("\nThe reversed string is:");
  puts(str);
  getch();
}

Find More from our code collection
Armstrong number, binary number to a decimal number, bubble sort, decimal number to binary number, factorial of the given number factors, fibonacci numbers, HCF and LCM, matrix, mergesort, salary of the employee. palindrome, quadratic equation, star patterns, series etc. and much more...
#Return to Example Source Code