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
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
Write a program of prime number using recursion.
What is dangling pointer in c?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..
What is the need of structure in c?
Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?
What is #define used for in c?
I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.
Is it acceptable to declare/define a variable in a c header?
What is multidimensional arrays
What is main () in c language?
Explain what standard functions are available to manipulate strings?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
What is an endless loop?