What is the fault in the following code plz help me soon thank U!

Write your question here.
#include<iostream.h>
#include<conio.h>
/*Function Prototype*/
int counting(int b[],int,int);

/*Main Method*/
int main (void)
{ clrscr();
int a[10],x,y,r,h=1;
for(x=0;x<10;x++) /* Input values for 10 times*/
{
cout<<"Enter the "<<h<<" Element : ";
cin>>a[x];
h++;
}

for(x=0;x<10;x++)
{if(r>1)
{
cout<<"Element "<<a[x]<<" repeats"<<count_repeats(a,a[x],x);<<" times \n";
}
} return 0;

}


/*Function that counts repitions of array elements*/
int counting(int b[],int c,int d)
{
int rep = 0;
for(int x=d;x<=10;x++)
{
if(b[x]==c)
rep++; /*search for duplication count*/
d--;
}
return rep;
}
try to compile it and get rid of errors it shows
Last edited on

Where is the clrscr() function, or are you using Turbo C++?, also what is count_repeats?

Also, you need to include the namespace for std, i.e. std::cout << "This is a test" << std::endl; unless you include using namespace std; at the top.
The single-letter variable names make the code very difficult to decipher. in this short example, it's possible to solve the puzzle, but reading program code should not be made such a mystery. Use sensible, meaningful names for variables and life becomes easier for both the person who wrote the code, as well as anyone else who might need to read and understand the code.
i am using turbo c++
Topic archived. No new replies allowed.