answersLogoWhite

0


Best Answer

#include <stdio.h>

#include <string.h>

void main()

{

char a[4][25],temp[25];

int i,j;

clrscr();

printf("Enter the names\n");

for (i=0;i<4;i++)

gets(a[i]);

for (i=0;i<3;i++)

for (j=i+1;j<4;j++)

{

if (strcmp(a[i],a[j])>0)

{

strcpy(temp,a[i]);

strcpy(a[i],a[j]);

strcpy(a[j],temp);

}

}

printf("Sorted strings are \n");

for (i=0;i<4;i++)

puts (a[i]);

getch();

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

write a program inclanguage toaccept 10 string as input and print them in lexicographic order?

ans:

#include<stdio.h>

#include<conio.h>

void main()

{

char *t,*str[10],s[10][50];

int i,j;

str[0]=s[0];

clrscr();

printf("Input ten strings\n");

for(i=0;i<10;i++)

{

gets(s[i]);

fflush(stdin);

}

for(i=0;i<10;i++)

{

for(j=i+1;j<10;j++)

{

if( ( strcmp( str[i],str[j]) ) > 0)

{

t=str[i];

str[i]=str[j];

str[j]=t;

}

}

}

for(i=0;i<10;i++)

printf("%s",str[i]);

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Homework. I'll give you some pseudo-code.

create array of strings

sort them lexicographically (str 1, str 2)

{

integer i

while strings are the same, increment i

if 1[i] is above 2[i], return 1. Else, return 2.

}

print array of strings.

Voilá!

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in c language to accept 10 strings as input and printthem in lexicographic order?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is lexicographic order?

Lexicographic order is an order function - a way of sorting information. It is generally a simple and useful way to sort strings. The name comes from the order used in a dictionary, where strings are compared in alphabetical order, from left to right. For more information, see the related link.


What is the Program for compare two strings using OR operator in java?

The String class includes two helpful methods: equals and compareTo.string1.equals(string2) will return true if the two strings contain the exact same charactersstring1.compareTo(string2) will return an int which describes the lexicographic relationship between the two strings. It will return a negative value if string1 is "less than" string2, a positive value if string1 is "greater than" string2, or zero if the two are equivalent strings.


Where string arrays belong in a C program?

There is no data type string in C. String is handled as an array of characters. To identify the end of the string, a null character is put. This is called a null terminated character array. So array of strings will be a double dimensioned array of chars. It is implemented as an array of pointers, each pointer pointing to an array of chars.


What purpose do strings serve in programming?

Strings are a type of variable in computer programming. Simply put, they contain multiple characters which are "strung" together to make a piece of text. "Test", "House", and "Hello World!" are all excellent examples of what might be contained in a string. As a result, strings are used to store and convey any textual information.


Can you tell me a C program to find if the strings are equal using pointers?

It is called strcmp, part of the standard run-time library. Returns 0 if the two strings are equals, non-zero otherwise.

Related questions

Write a program in 'C' language to accept 6 strings as input and print them in lexicographic?

(ab)*b


What is lexicographic order?

Lexicographic order is an order function - a way of sorting information. It is generally a simple and useful way to sort strings. The name comes from the order used in a dictionary, where strings are compared in alphabetical order, from left to right. For more information, see the related link.


How can you do the same thing as the program below but using strings and arrays in C language?

Program below?!


Write a program in 'c' language that accepts 10 strings as input and prints them in lexicographic order?

#include &lt;stdio.h&gt; #include &lt;string.h&gt; void main() { char a[4][25],temp[25]; int i,j; clrscr(); printf("Enter the names\n"); for (i=0;i&lt;4;i++) gets(a[i]); for (i=0;i&lt;3;i++) for (j=i+1;j&lt;4;j++) { if (strcmp(a[i],a[j])&gt;0) { strcpy(temp,a[i]); strcpy(a[i],a[j]); strcpy(a[j],temp); } } printf("Sorted strings are \n"); for (i=0;i&lt;4;i++) puts (a[i]); getch(); }


What is the Program for compare two strings using OR operator in java?

The String class includes two helpful methods: equals and compareTo.string1.equals(string2) will return true if the two strings contain the exact same charactersstring1.compareTo(string2) will return an int which describes the lexicographic relationship between the two strings. It will return a negative value if string1 is "less than" string2, a positive value if string1 is "greater than" string2, or zero if the two are equivalent strings.


Where string arrays belong in a C program?

There is no data type string in C. String is handled as an array of characters. To identify the end of the string, a null character is put. This is called a null terminated character array. So array of strings will be a double dimensioned array of chars. It is implemented as an array of pointers, each pointer pointing to an array of chars.


Why is No Strings Attached rated R?

No Strings Attached (2011) is rated R for sexual content, strong language, and some drug material.


How can you create a DLL file to change language in a software?

I assume you are referring to a case where the software does not have the resource strings in other languages. Hence it is not just a language setting. Assuming you have coded/designed the software appropriately (not embedded the resource strings within the code, rather separated the code from the strings - by strings I refer to the text, error messages etc that are displayed to the user), you would need to (a) create another file containing the resource strings in the new language (b) compile and create the new resource dll and (c) get the software to use this new dll based on the user's language.


Write a c program to copy two strings using pointers?

nahi malum


What purpose do strings serve in programming?

Strings are a type of variable in computer programming. Simply put, they contain multiple characters which are "strung" together to make a piece of text. "Test", "House", and "Hello World!" are all excellent examples of what might be contained in a string. As a result, strings are used to store and convey any textual information.


How do you print strings and numbers in single statement by using C language?

With printf.Example:for (i=0; i


Controlling program flow strings of prolog?

In prolog, you dont control the flow. The flow controls you.