Write a program in C’ that accepts 10 words of varying length and arranges the words in the descending order of word length. Use arrays. 10m Dec2006

By | June 23, 2014

Write a program in C’ that accepts 10 words of varying length and arranges the words in the descending order of word length. Use arrays. 10m Dec2006

#include<stdio.h>
#include<string.h>
void main()
{
int i,j;
char array[10][10],temp[10];
clrscr();
printf(“Enter ten words : \n”);
for(i=0;i<10;i++)
{
printf(“%d : “,i+1);
gets(array[i]);
}
for(i=0;i<10;i++)
{
for(j=i;j<10;j++)
{

if(strlen(array[i])<strlen(array[j]))
{

strcpy(temp,array[i]);
strcpy(array[i],array[j]);
strcpy(array[j],temp);
}
}
}
printf(“\nSorted ten words are : \n”);
for(i=0;i<10;i++)
{
printf(“%s \n”,array[i]);
}
getch();
}

 

[codesyntax lang=”c”]

c#include<stdio.h>
#include<string.h>
void main()
{
int i,j;
char array[10][10],temp[10];
clrscr();
printf("Enter ten words : \n");
for(i=0;i<10;i++)
{
printf("%d : ",i+1);
gets(array[i]);
}
for(i=0;i<10;i++)
{
for(j=i;j<10;j++)
{

if(strlen(array[i])<strlen(array[j]))
{

strcpy(temp,array[i]);
strcpy(array[i],array[j]);
strcpy(array[j],temp);
}
}
}
printf("\nSorted ten words are : \n");
for(i=0;i<10;i++)
{
printf("%s \n",array[i]);
}
getch();
}

[/codesyntax]

Screen Shots:

C_program_Sort_Word

 

C_program_Sort_Word_Output

 

 

Write a program in ‘C’ for the multiplication of two matrices. 10m Dec2006

Solved program can be found on this link http://cssimplified.com/c-programming/an-interactive-c-program-to-multiply-two-matrices

 

Leave a Reply