EXAMINATION SCAM 3
Examination Scam 3
Now a days in online examination there has been many fraudulent activities.Since online examination takes place virtualy its easy for the corrupts to gain money from it.
One such fraudulent activity is providing fake registration links to the participants and collecting the fee from them.Due to this activity the legitimate online examination boards are hindered.As they are the once held responsible for the fees collected.There is also the case of an applicant registering using fake credentials.Applying more then once for a particular examination.
To curb such bogus registration, the government has decided to tag the Aadhar number with every application. Then it collates the list of Aadhar numbers available in all application in the region. The authorities want to detect whether a particular Aadhar number appears multiple times in the list.
Can you help them by writing a program to count the number of times 5 appears in an array?
Note : Formulate a RECURSIVE Algorithm
Use malloc method to create the array.
Function name: int duplicateFive(int *,int);
Input Format:
The first line of the input consists of a single integer that corresponds to ‘n’, the number of elements in the array.
The next line of the input consists of ‘n’ space separated integers that correspond to to the elements in the array.
Output Format:
Output consists of a single integer that corresponds to the number of times the 5 appears in the array.
Sample Input :
5
3 7 5 9 5
Sample Output :
2
#include
#include
int duplicateFive(int *a,int n);
int main()
{
int i,*p,n,ans;
scanf("%d",&n);
p=(int*)malloc(n*sizeof(int));
for(i=0;i0)
{
int c=0;
if((*(a+n-1))==5)
{
c++;
return (c+duplicateFive(a,n-1));
}
else return duplicateFive(a,n-1);
}
else return 0;
}
Comments
Post a Comment