simple c program for 12345 convert 54321 with out using string

Answer Posted / rajan sonvane

#include<stdio.h>
#include<conio.h>
main()
{
int *p,a[5]={1,2,3,4,5},b[5],i=0;
p=a;
while(i<5)
{

b[i]=*(p+4-i);

i++;
}
for(i=0; i<5; i++)
{
printf("%d",b[i]);
}
getch();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where define directive used?

693


What is the benefit of using an enum rather than a #define constant?

768


Explain 'far' and 'near' pointers in c.

795


#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }

877


Write a program to print fibonacci series using recursion?

706






What is a 'null pointer assignment' error?

815


What is the difference between struct and typedef struct in c?

755


What is malloc and calloc?

677


How do you redirect a standard stream?

732


Why header file is used in c?

670


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

711


What is the heap?

804


Write a simple code fragment that will check if a number is positive or negative.

796


What is int main () in c?

723


I need testPalindrome and removeSpace #include #define SIZE 256 /* function prototype */ /* test if the chars in the range of [left, right] of array is a palindrome */ int testPalindrome( char array[], int left, int right ); /* remove the space in the src array and copy it over to the "copy" array */ /* set the number of chars in the "copy" array to the location that cnt points t */ void removeSpace(char src[], char copy[], int *cnt); int main( void ) { char c; /* temporarily holds keyboard input */ char string[ SIZE ]; /* original string */ char copy[ SIZE ]; /* copy of string without spaces */ int count = 0; /* length of string */ int copyCount; /* length of copy */ printf( "Enter a sentence:\n" ); /* get sentence to test from user */ while ( ( c = getchar() ) != '\n' && count < SIZE ) { string[ count++ ] = c; } /* end while */ string[ count ] = '\0'; /* terminate string */ /* make a copy of string without spaces */ removeSpace(string, copy, ©Count); /* print whether or not the sentence is a palindrome */ if ( testPalindrome( copy, 0, copyCount - 1 ) ) { printf( "\"%s\" is a palindrome\n", string ); } /* end if */ else { printf( "\"%s\" is not a palindrome\n", string ); } /* end else */ return 0; /* indicate successful termination */ } /* end main */ void removeSpace(char src[], char copy[], int *cnt) { } int testPalindrome( char array[], int left, int right ) { }

2314