C program to reverse an array without using another array/*C program to reverse an array without using another array*/#include< stdio. Enter number of elements to insert in an array: "); scanf("%d",& len); printf("Enter elements to insert in an array: "); for(i=0; i< len; i++){scanf("%d",& t); arr[i]=t; }printf("\n. Original Array is "); for(i=0; arr[i]!='\0'; i++){printf("%d ",arr[i]); }/*****************************/j=len- 1; for(i=0; i& lt; =(len/2); i++){tmp=arr[i]; arr[i]=arr[j]; arr[j]=tmp; j- -; }/*****************************/printf("\n reverse is "); for(i=0; arr[i]!='\0'; i++){printf("%d ",arr[i]); } getch(); return.
Write a program to reverse a string (i) using another array, (ii) without another array.#include< iostream. Enter a string : "; gets(str); int l = strlen(str); /* Reverse String using another array */ for( int i = l- 1, k = 0 ; i> = 0 ; i- -, k++) rev[k] = str[i]; rev[k] = '\0'; cout< < "\n Original String is "< < str; cout< < "\n Reverse String is "< < rev ; cout< < "\n Reverse String is "; /* Reverse String without using another array */ for( i = l- 1 ; i> =0 ; i- -) cout< < str[i]; getch(); }. C program to reverse an array without using another array. Write a C program to reverse an array without using another array. (' \n reverse is '). Is it possible to reverse string array without using any temp. when I started to ask another question about his program. C Languages Java Visual Basic Web. Campus Ambassador Program. // Iterative C program to reverse an array #include<stdio.h. There is a pretty standard to swap without using the third. C Program to Compare two Strings without using strcmp; C Program to Check whether the Given String is a Palindrome. C program to reverse an array using pointers. Given below is the c code to reverse an array. C programming code. Output of program: Reverse array by swapping (without using. C program to reverse an array.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
September 2016
Categories |