Read a number series and print it reversed

clarence_cool03 0 Tallied Votes 116 Views Share

{-='Read a number series and print it reversed using Dev-C LaNGuaGe'=-}

#include <stdio.h>

int main (void)
{
//	Local Declarations 
    int readChar;
	int characters[50];
    int i, charPrinted;

//	Statements 
    printf("You may enter up to 50 characters:\n");
	//printf("How many would you like to enter? ");
	//scanf (" %c", &readChar);
	
	//if (readChar > 50)
	   // readChar = 50;
	
//  Fill the array 
	
	printf("\nEnter your characters: \n");
	for (i = 0; i < 50; i++)
	     scanf(" %c", &characters[i]);
	     
//  Print the array 
	
	printf("\nYour numbers reversed are: \n");
	for (i = readChar - 1, charPrinted = 0; 
	         i >= 0;
	         i--)
	   {
	    printf("%3c", characters[i]);
	    if (charPrinted < 9)
	        charPrinted++;
	    else
	       {
	        printf("\n");
	        charPrinted = 0;
	       }// else 
	   }// for 
	   
	system("pause");   
	return 0;
}// main 

/*	Results:
You may enter up to 50 integers:
How many would you like to enter? 12

Enter your numbers: 
1 2 3 4 5 6 7 8 9 10 11 12

Your numbers reversed are: 
 12 11 10  9  8  7  6  5  4  3
  2  1
*/