Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

A array contains dissimilar element how can we count,
and
A array contains dissimilar element how can we store in
another array with out repetition.

Answer Posted / vadivel t

Hi this code ll work for the second question but first
question i dint understand...

here in souce buff we have 16 nos, in which 1 to 5 repeats
3 times.

but at the end of the program u ll get only nos 1 to 6 as
out in dest buff without duplicate.


Note: Compiler used Visual studio 2005.


#include<stdio.h>
#include<conio.h>
void main()
{
int source[16] = {5,3,4,1,2,1,2,3,4,5,2,3,1,5,4,6};
int dest[6], i, j, count = 0, flag;

int test = 0;
/*Copy the first element*/
dest[0] = source[0];
count++;
for(i = 1; i<= 15; i++)
{
/*Check whether the same element is already
available in the dest buff*/
for(j = 0; j<count; j++)
{
if(dest[j] == source[i])
{
/*Already available*/
flag = 0;
break;

}
else
{
flag = 1;
}
}
if(flag == 1)
{
/*The same element is not available
already - so copy it to the dest buffer*/
dest[count] = source[i];
count++;
}
}

for(i = 0; i<=5; i++)
printf("%d\t",dest[i]);

_getch();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Calculate 1*2*3*____*n using recursive function??

2097


please explain every phase in the "SDLC" in the dotnet.

2668


What is maximum size of array in c?

1085


What functions are used in dynamic memory allocation in c?

1119


What's the difference between constant char *p and char * constant p?

1191


Explain how do you convert strings to numbers in c?

1125


What is file in c preprocessor?

1195


Explain how to reverse singly link list.

1202


What are the different data types in C?

1249


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

2121


Explain how do you search data in a data file using random access method?

1175


What are structures and unions? State differencves between them.

1251


FILE PROGRAMMING

2296


What does sizeof int return?

1132


Can I initialize unions?

1090