🔒 Closed Create a program that accepts a number as an input. The program will then check an array if the value is inside or not.

Status
Not open for further replies.

Ph_Bunker

Forum Veteran
You do not have permission to view the full content of this post. Log in or register now. <stdlib.h>
You do not have permission to view the full content of this post. Log in or register now.<stdio.h>
int main ()
{ srand(time(NULL));
int array[10];
for(int init=0;init<10; init++){
array[init] = (rand() % 20) + 1;
} printf("Array values: ");
for(int i=0;i<10; i++){
printf("%d ", array);
} printf("\n\n");
//your code here}



Example 1:
Array values: 2 4 1 3 4 12 16 10 9 18
Sorted: 1 2 3 4 4 9 10 12 16 18

Example 2:
Array values: 5 1 3 4 12 11 19 18 9 6
Sorted: 1 3 4 5 6 9 11 12 18 19


My coding:

#include <stdlib.h>
#include<stdio.h>

int main () {
srand(time(NULL));
int array[10];

for(int init=0;init<10; init++){
array[init] = (rand() % 20) + 1;
}
printf("Array values: ");
for(int i=0;i<10; i++){
printf("%d ", array);
}
printf("\n\n");

int i;

printf("Number to search for:");
scanf("%d",&array);

if(i<=array){
printf("Result: Number exists in array");
}else{
printf("Result: Number does not exist in array");
}
}
help me....
 
Status
Not open for further replies.

About this Thread

  • 7
    Replies
  • 466
    Views
  • 5
    Participants
Last reply from:
Equilibrium

Online now

Members online
1,050
Guests online
1,013
Total visitors
2,063

Forum statistics

Threads
2,277,028
Posts
28,973,808
Members
1,229,693
Latest member
riogab
Back
Top