Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why is not excecuting? C program

0 votes
asked Mar 16, 2018 by anonymous
edited Mar 16, 2018

#include <stdio.h>

int prime(int arr[], int size) {

int i, j;

for(i=0; i<size; i++) {

for(j=i+1; j<size; j++) {

if(arr[i] == arr[j])

return 1; // has duplicate

}

}

return 0; // no duplicate

}

int linear(int arr[], int size, int x) {

int i;

for(i=0; i<size; i++) {

if(arr[i] == x)

return 1;

}

return 0; // not found

}

int main() {

int arr[50], n, i,k;

printf("Number of integers: \n");

scanf("%d", &n);

printf("Enter %d integers: \n", n);

for(i=0; i<n; i++)

scanf("%d", &arr[i]);

if(prime(arr, nc))

printf("Array contains duplicates\n");

else

printf("Array does not contains duplicates\n");

printf("Enter number to search: ");

scanf("%d", &k);

if(linear(arr, n, k)){

printf("%d is in array\n", k);

}else{

printf("%d is not in array\n", k);

}

}

1 Answer

0 votes
answered Mar 16, 2018 by anonymous
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...