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

Write a program to print fibonacci series using recursion?

1001


Why do we use static in c?

1063


What is type qualifiers?

1072


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

957


What is difference between structure and union in c?

919


What are operators in c?

961


What is the use of static variable in c?

1040


What is the value of h?

983


What are shell structures used for?

982


What are the different categories of functions in c?

1077


What is the value of c?

1004


difference between Low, Middle, High Level languages in c ?

2022


What is the use of getch ()?

1030


How to compare array with pointer in c?

1046


What is character set?

1112