Friday 20, July 2018
Welcome Guest, Register | Login  
      Home       Tutorials       Free Ebooks       Free Scripts       Tech News       Articles       About Us       Blog        Forum

  C Program to Reverse an array

Here is a program which will take input from user in array and will reverse it using c language.
Cut & Paste Script

#include<stdio.h>
#include<conio.h>
void read(int *,int);
void dis(int *,int);
void inverse(int *,int);

main(){

   int a[5],i;

   read(a,5);
   dis(a,5);
   inverse(a,5);
   dis(a,5);
   getch();
}

void read(int c[],int i)
{
   int j;
   printf("Enter the list \n");
   for(j=0;j<i;j++)
      scanf("%d",&c[j]);
   fflush(stdin);
}
void dis(int d[],int i)
{
   int j;
   printf("The list is \n");
   for(j=0;j<i;j++)
      printf("%d ",d[j]);
   printf("\n");
}
void inverse(int inver_a[],int j)
{
   int i,temp;
   j--;
   for(i=0;i<(j/2);i++)
   {
      temp=inver_a[i];
      inver_a[i]=inver_a[j];
      inver_a[j]=temp;
      j--;
   }
}
   
     RELATED SCRIPTS
 
concatenate two strings c language
Here is an example code to concatenate two strings using clanguage....more »
Category : C Programs Hits : 3349
   
C program to show memory address of array elements and access array elements using pointers
This program will visualize the memory address of each array element and will show you how to access array elements using pointer....more »
Category : C Programs Hits : 3194
   
Bubble sort using c language
This program will sort an array using bubble sort in c language. c program for bubble sort, bubble sort in c, sorting an array using bubble sort in c language....more »
Category : C Programs Hits : 3840
   
Check number is prime or not using c

Here is a code example to check the number is prime or not a prime number. It will input number from user. If number is prime, it will print "Number is prime" on screen and if number is not prime it will print "Number is not prime".

...more »
Category : C Programs Hits : 5599
   
arrays and pointers in c
An example code for arrays and pointers in c language....more »
Category : C Programs Hits : 2022
   
   
SCRIPT CATEGORIES
 
  C Programs
C Programs scripts
  C++ Programs
C++ Programs scripts
  Java Programs
Java Programs scripts
  JavaScript Examples
JavaScript Examples scripts
  PHP Examples
PHP Examples scripts
  VBScript Examples
VBScript Examples scripts
 
 
 
POPULAR E-BOOKS
 
Download Closing the Sale Ebook Closing the Sale
   
Download C# Development Ebook C# Development
   
Download The Definitive Guide to symfony  Ebook The Definitive Guide to symfony
   
Download Blueprints for a successful presentation  Ebook Blueprints for a successful presentation
   
Download Make Your Price Sell  The Master Course  Ebook Make Your Price Sell The Master Course
   
Studiesinn.com 2018 All Rights Reserved.