www.vustudents.ning.com

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

# CS201 Assignment#2 Idea Solutions

CS201 Assignment#2 Idea Solutions. Its not 100% sure solution. Try to make 100% by your self.....it’s just for help...Do not copy and past please.....

Idea Solution#1

you didn't specify the range of the numbers that can be input, I made it any number--would have been much simpler for the numbers 0 to 9 only

#include <iostream>
using namespace std;
void finddups(int[],int);
int main()
{int a[10],i;
for(i=0;i<10;i++)
{cout"Enter the value of\narray element "i+1": ";
cin>>a[i];
}
finddups(a,10);
system("pause");
return 0;
}
void finddups(int a[],int n)
{int i,j,k=0,b=0,c,dups[n];
bool done,first;
for(i=0;i<n;i++)
dups[i]=0;
for(i=0;i<n-1;i++)
{c=1;
done=false;
for(k=0;k<b;k++)
if(a[i]==dups[k])
{done=true;
}
if(!done)
{first=true;
for(j=i+1;j<n;j++)
{if(a[i]==a[j])
{ c++;
if(first)
{first=false;
dups[b]=a[i];
b++;
}
}
}
}
if(c!=1)
couta[i]" is repeated "c"\ntimes\n";

}
if(b==0)
cout"There is no repetition in the array\n";
}

Views: 57

Attachments:

1

2

3

4

5

## VIP Member Badge & Others

------------------------------------

## Latest Activity

1 hour ago
++ACHJ-- added a discussion to the group MGT503 Principles of Management

### MGT 503 Assignment 1 solution \\ 100% ok solution with detailed discussion

1 hour ago
++ACHJ-- joined + M.Tariq Malik's group

### MGT503 Principles of Management

1 hour ago
2 hours ago
Dream♥Girl updated their profile
3 hours ago
Fratino and HAROON "DOLPHIN POLICE" joined + M.Tariq Malik's group

### EDU303 Child Development

3 hours ago
Aasma added a discussion to the group PAK301 Pakistan Studies

4 hours ago