Home
Questions
Search
Forum
Contact
Guest Book
Polls!
Got a Question?
 
PREV
Programs
NEXT
 
(51 / 301)
 
 



Finding a duplicated integer problem




Given an array of n integers from 1 to n with one integer repeated..

Here is the simplest of C programs (kind of dumb)


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

int i,j=0,k,a1[10];

main()
{
     printf("Enter the array of numbers between 1 and 100(you can repeat the numbers):");
     for(i=0;i<=9;i++)
     {
         scanf("%d",&a1[i]);
     }
     
     while(j<10)
     {
        for(k=0;k<10;k++)
        {
            if(a1[j]==a1[k] && j!=k)
            {
                printf("Duplicate found!");
                printf("The duplicate is %d\n",a1[j]);
                getch();
            }
        }
        j=j+1;
    }
    
    getch();
    return(0);
}



PREV
COMMENTS                                  INDEX                                  PRINT
NEXT



Last updated: November 3, 2005

www.cracktheinterview.com - Your destination for the most common IT interview questions, answers, frequently asked interview questions (FAQ), C Programs, C Datastructures for technical interviews conducted by the top IT companies around the world!