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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
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
1.find the second maximum in an array?
2.how do you create hash table in c?
3.what is hash collision
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision
Answer
# 1
#include<stdio.h>
#include<conio.h>
void soft(int *,int *);
void main()
{
int a[30],n;
printf("enter the number of elements going to enter :");
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",a[i]);
soft(a);
printf("the second maximum in the given array is :");
getch();
}
void soft(int *a,int *n);
{
 int temp;
for(int i=0;i<(*n);i++)
  {
    for(j=0;j<(*n);j++)
       { 
         if(a[j+1]<a[j])
          {
             temp=a[j+1];
       a[j+1]=a[j];
     a[j]=temp;
}
}
}
printf("%d",a[n-1]);
}

sorry i dont know the concept of hash table!!!!!!!!!!!!!!!
 
Is This Answer Correct ?    0 Yes 11 No
Vignesh1988i
 
  Re: 1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision
Answer
# 2
#include <stdio.h>

int main ( int argc, char* argv[] )
{

	int* array_int, nTotalCount = 10, sbig, big, i;
	printf ( "\n/********************** Second Biggest 
Number ********************/" );
	array_int = ( int* ) malloc ( nTotalCount * sizeof 
( int ) );

	for ( i = 0; i < nTotalCount; i++ )
		array_int [i] = rand() % 100;

	printf( "\nThe Numbers in given order" );
	for ( i = 0; i < nTotalCount; i++ )
		printf ( "\t%d", array_int [i] );

	for ( i = 0; i < nTotalCount; i++ )
	{
		switch ( i )
		{
			case 0:
				sbig = big = array_int [i];
				break;
			default:
				if ( big < array_int [i] ) {
					sbig = big;
					big = array_int [i];
				} else {
					if ( sbig < 
array_int [i] ) sbig = array_int [i] ;
				}
				break;
		}
	}
	printf ( "\n sbig :%d big :%d", sbig, big );

	free ( array_int );
}


For hashtable please refer the following link
http://www.geocities.com/abdur_rab7/Open_Hash/openhash.html
 
Is This Answer Correct ?    3 Yes 2 No
Abdur Rab
 
 
 
  Re: 1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision
Answer
# 3
1.#include<stdio.h>
int main()
{
    int a[10]={222,111,4,5,6,8,1,77,0,4};
    int i=0,max=0,sec_max=0;
    
    for(i=0;i<10;i++)
    {
       if(a[i]>max)
       {
         sec_max=max;
         max=a[i];	
       }
       else if(a[i]>sec_max)
       {
       	  sec_max=a[i];
       }
       	
    	
    }
    
printf("Max= %d  Second Max=%d",max,sec_max);
    
}
 
Is This Answer Correct ?    11 Yes 1 No
Sachin
 
  Re: 1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision
Answer
# 4
#include<stdio.h>

int main()
{
        int arr[] = {2,3,20,7,8,1};
        int max, sec;
        int i;
        max=0;
        sec=0;
        for ( i=0; i< 6; i++)
        {
                if(arr[i] > max)
                max = arr[i];
        }

        for ( i=0; i< 6; i++)
        {
                if ( (arr[i] > sec) && (arr[i] < max))
                        sec = arr[i];
        }
        printf(" max=%d\n sec=%d\n", max, sec);
}
 
Is This Answer Correct ?    1 Yes 0 No
Rao
 
  Re: 1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision
Answer
# 5
//find second maximum number in given array. 
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[5];
int max=0,secmax=0,i;
cout<<"Enter element";
for(i=0;i<=4;i++)
{
cin>>a[i];
}
for(i=0;i<=4;i++)
{
if(a[i]>max)
{
secmax=max;
max=a[i];
}
if(a[i]>secmax&&a[i]<max)
{
 secmax=a[i];
}
}
cout<<"The max element is="<<max;
cout<<"the sec max is="<<secmax;
getch();
}
 
Is This Answer Correct ?    0 Yes 0 No
Jaypal Rajput
 
  Re: 1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision
Answer
# 6
1. Selection sort with second pass
2. Basically we create a two dimension array (key, value)
and then we define a hash function to determine position of
elements when we insert/delete.
3. When two elements insert to the same spot in a hash
table, we have a hash collision. H(x1) = H(x2) = y
 
Is This Answer Correct ?    0 Yes 0 No
Steven Le
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what is the first address that gets stored in stack according to a C or C++ compiler???? or what will be the first address that gets stored when we write a C source code???????? Apple2
How can I invoke another program from within a C program?  6
How do you write a program which produces its own source code as its output?  2
How can I read a directory in a C program? Wipro1
What is volatile in c language? HCL1
What compilation do? Geometric-Software7
Consider a language that does not have arrays but does have stacks as a data type.and PUSH POP..are all defined .Show how a one dimensional array can be implemented by using two stacks. Google3
write a program to compare 2 numbers without using logical operators? IBM1
Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)  2
main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } CitiGroup7
Write a function that accepts two numbers,say a and b and makes bth bit of a to 0.No other bits of a should get changed. Scientific-Atlanta2
can anyone please tell me wat is backlogs... i was looking for the job openings where i read this.. eligibility criteria minimum 70% in degree without backlogs. is that arrear.. if so is it standing arrear or history of arrears... please help me...  4
how to add numbers without using arithmetic operators. TCS10
what are two categories of clint-server application development ?  1
int i =10 main() { int i =20,n; for(n=0;n<=i;) { int i=10 i++; } printf("%d", i); HCL5
Evaluate the following: int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; } for fn(7); 1) 10 2) 11 3) 1  6
void main() { int i=5; printf("%d",i++ + ++i); } ME11
If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit.  4
5. What kind of sorting is this: SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort Accenture2
Struct(s) { int a; long b; } Union (u) {int a; long b; } Print sizeof(s)and sizeof(u) if sizeof(int)=4 and sizeof(long)=4 Mascot2
 
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