ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
program to find the second largest word in a paragraph 
amongst all words that repeat more thn twice
 Question Submitted By :: Pavani
I also faced this Question!!     Rank Answer Posted By  
 
  Re: program to find the second largest word in a paragraph amongst all words that repeat more thn twice
Answer
# 1
why no body is helping me in this matter
 
Is This Answer Correct ?    1 Yes 1 No
Pavani
 
  Re: program to find the second largest word in a paragraph amongst all words that repeat more thn twice
Answer
# 2
Hi Pavani,
My name is Kiran.

Iam posting the code for ur Question.

The code is given below.

/* Program to find the second larges word in a paragraph 
   amongst all words that repeat more than twice */

# include <stdio.h>
# include <stdlib.h>

int main(void)
{
	char para[80],*temp1=NULL,*temp=NULL,*first_high,*second_high;
	unsigned int first_high_len,second_high_len;
	printf("Enter the Paragraph\n");
	fgets(para,80,stdin);
	
	temp=strchr((const char*) para, (int)' ');
	temp=para;
	temp=strchr((const char*)para,(int)' ');     /* Assuming
first word as the first highest
                                                        word
and storing word and the number of
                                                       
letters of that word */
	first_high_len=temp-para;
	first_high=malloc(first_high_len+1);
	strncpy(first_high, (const char*) para, first_high_len);
	*(first_high+first_high_len)='\0';
	
	temp1=strchr((const char*)temp+1,(int)' '); /* Assuming
second word as the second highest
                                                       word
and storing the word and the number of
                                                      
letters of that word */
	second_high_len=temp1-temp-1;
	second_high=malloc(second_high_len+1);
	strncpy(second_high, (const char*) temp+1, second_high_len);
	*(second_high+second_high_len)='\0';
   
	while(1)
	{
		temp1=strchr((const char*)temp+1,(int)' ');
	if(temp1 == NULL)
		break;
	if(temp1-temp-1 > first_high_len)
	{
		free(second_high);  
		second_high=malloc(first_high_len+1);
                second_high_len=first_high_len;	
		strncpy(second_high, (const char*) first_high,
second_high_len);
		*(second_high+second_high_len)='\0';   
		free(first_high);
	           
		first_high=malloc(temp1-temp);
		first_high_len=temp1-temp-1;
		strncpy(first_high, (const char*) temp+1, first_high_len);
		*(first_high+first_high_len)='\0';
	}
	
	else if(second_high_len < (temp1-temp-1) && first_high_len
!= (temp1-temp-1))
	{
		free(second_high);
		second_high=malloc(temp1-temp);
		second_high_len=temp1-temp-1; 
		strncpy(second_high, (const char*) temp1+1, second_high_len);
		*(second_high+second_high_len)='\0';
	}
	
	temp=temp1;
        }


	if(strlen((const char*)temp+1) > first_high_len)
	{
		free(second_high);
		second_high=first_high;   
		first_high=temp+1;
	}
 
	else if(strlen((const char*)temp+1) > second_high_len  && 
strlen((const char*)temp+1) != first_high_len)
	{
		free(second_high);
		second_high=temp+1;
	}

	printf("\nFirst  Highest word = %s , Len =
%d",first_high,first_high_len);
	printf("\nSecond Highest word = %s , Len = %d",second_high,
second_high_len);
	return 0;
}


Check this code  if u have any queries please be free
to ask any queries.
Email : kirjony@gmail.com
 
Is This Answer Correct ?    2 Yes 0 No
Kiran Kumar
 
 
 
  Re: program to find the second largest word in a paragraph amongst all words that repeat more thn twice
Answer
# 3
By simple

1.find length of each word
2.insert into binary search tree
3.recursively get the left most child of the right sub tree. finally you will get the second largest word.

via this logic you can smallest word,largest word.

is it have criticize?? mail me rainpearls.v@gmail.com
 
Is This Answer Correct ?    1 Yes 0 No
Marimuthu
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
2. Counting in Lojban, an artificial language developed over the last fourty years, is easier than in most languages The numbers from zero to nine are: 0 no 1 pa 2 re 3 ci 4 vo 5 mk 6 xa 7 ze 8 bi 9 so Larger numbers are created by gluing the digit togather. For Examle 123 is pareci Write a program that reads in a lojban string(representing a no less than or equal to 1,000,000) and output it in numbers. Nagarro2
write a fuction for accepting and replacing lowercase letter to'Z' with out using inline function. Temenos4
How to set a variable in the environment list?  1
how to find turn around time in operating system?  1
what is the difference between declaration and definition of a variable or function ?  2
to find the program of matrix multiplication using arrays  2
convert 12345 to 54321 withoutusing strig  3
where does malloc() function get the memory?  1
Write a program to accept a character & display its corrosponding ASCII value & vice versa?  4
how can i get output like this? 1 2 3 4 5 6 Excel3
what is Structural oriented language? give some example of this language.....?  1
study the code: #include<stdio.h> void main() { const int a=100; int *p; p=&a; (*p)++; printf("a=%dn(*p)=%dn",a,*p); } What is printed? A)100,101 B)100,100 C)101,101 D)None of the above Accenture13
If we give two names then this displays the connection between the two people. It is nothing but flames game  1
How do you write a program which produces its own source code as its output?  2
To what value do nonglobal variables default? 1) auto 2) register 3) static  4
what is the defrenece between structure and union  5
Difference between Class and Struct. Motorola6
Program to display given 3 integers in ascending order N-Tech1
Two's compliment of -5 Adobe3
helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.  3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com