Search
 
SCRIPT & CODE EXAMPLE
 

C

Write a C program to find reverse of an array

#include <stdio.h>
#include <stdlib.h>
#define n 6
int main(){
    int arr[n] = {9, 8, 7, 2, 4, 3};
    int temp;
    for(int i = 0; i<n/2; i++){
        temp = arr[i];
        arr[i] = arr[n-i-1];
        arr[n-i-1] = temp;
    }
    for(int i = 0; i < n; i++){
        printf("%d,", arr[i]);
    }
}
Comment

reverse array in c

//reverse char array in c
void reverse(char array[]){
	int size = strlen(array); //include string.h to use strlen()
  	char rev[size];
  
  	for(int i=0; i<size; i++)
   		rev[size-1-i] = array[i]; 
      
	for(int i=0; i<size; i++)
    	array[i] = rev[i];
}
Comment

PREVIOUS NEXT
Code Example
C :: types of instruction and there meaning in c 
C :: boilerplate code c 
C :: size of an array c 
C :: take array as input in c 
C :: thread in c 
C :: postgres random select 
C :: two bytes to int c 
C :: how to read character from a string in c 
C :: clrscr in c 
C :: unity set transform position code 
C :: va_list in c 
C :: c assign pointer to struct 
C :: c check if character is a digit 
C :: c check if char is an operator 
C :: pthread c 
C :: c modify char array 
C :: c char to lower case 
C :: c style string 
C :: binary to decimal in c 
C :: grepper vscodium 
C :: How to convert string to int without using library functions in c 
C :: how to use malloc in c 
C :: how to read 2d array from a file in c 
C :: declare string in c 
C :: hourglass sum 
C :: create point cloud from rgbd image in open3d v0.10 
C :: fread 
C :: enum case statement in c 
C :: how to print logs when doing unit-testing in rust 
C :: C Syntax of struct 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =