Question #13150047

Alphabetical Order C Program?

I have made an array of strings. The Objective is to print them in Alphabetical order. My Code is given below .... Please help me ... I am not getting an output. #include <stdio.h> #include <string.h> int main() { char Name_Array[][10] = {"avinash", "sushil", "alok", "prateek", "prashanth", "naveen"}; int i, j, x; char t[10]; for (i=0; i<7; i++) { for (i=0, j=1; i<5, j<6; i++, j++) { x = strcmp(&Name_Array[i][0], &Name_Array[j][0]); if (x>0) { strcpy(t, &Name_Array[i][0]); strcpy(&Name_Array[i][0], &Name_Array[j][0]); strcpy(&Name_Array[j][0], t); } } } for (i=0; i<6; i++) { printf ("%s ", &Name_Array[i][0]); } printf(" "); return 0; }

2014-01-16 20:58:55

TELL US , if you have any answer

There is NEVER a problem, ONLY a challange!

The helpinganswers.com is a free-to-use knowledgebase.
  The helpinganswers.com was started on: 02.07.2010.
  It's free to register. Once you are a registered user, you can ask questions, or answer them.
  (Unless registration you can just answer the questions anonymously)
  Only english!!! Questions and answers in other languages will be deleted!!

Cheers: the PixelFighters

  Contact: support@helpinganswers.com

C'mon... follow us!

Made by, history, ect.