answersLogoWhite

0

#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

12y ago

What else can I help you with?

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.


How does every language reduce to its complement?

Every language can be reduced to its complement by taking the set of all possible strings and removing the strings that are in the original language. This process results in the complement language, which consists of all strings not in the original language.


Can you write a grammar for the language consisting of strings?

Yes, a grammar for a language consisting of strings can be written using production rules that define how strings can be formed. Each rule specifies how different parts of a string can be combined or modified. The grammar can include rules for creating basic strings, concatenating strings, repeating characters, and more complex patterns.


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


Is the empty set considered a regular language?

No, the empty set is not considered a regular language because it does not contain any strings or elements.