Enable contrast version

# Tutor profile: Geetika G.

Busy in a lesson
Geetika G.
Passionate tutor
Tutor Satisfaction Guarantee

## Questions

### Subject:Writing

TutorMe
Question:

Write a short story.

Inactive
Geetika G.

### Subject:Calculus

TutorMe
Question:

Let the interval (a , +infinity) be the range of function f. The range of f(x) - 4 is given by:

Inactive
Geetika G.

If the range of f is given by the interval (a , +infinity), we can write the following inequality f(x) > a add - 4 to both sides on the inequality to obtain f(x) - 4 > a - 4 The last inequality suggests that the range of f(x) - 4 is (a - 4, +infinity)

### Subject:C Programming

TutorMe
Question:

Write a C program to input elements in array and search whether an element exists in array or not.

Inactive
Geetika G.

Step by step descriptive logic to search element in array using linear search algorithm. 1. Input size and elements in array from user. Store it in some variable say size and arr. 2. Input number to search from user in some variable say toSearch. 3. Define a flag variable as found = 0. I have initialized found with 0, which means initially I have assumed that searched element does not exists in array. 4. Run loop from 0 to size. Loop structure should look like for(i=0; i<size; i++). 5. Inside loop check if current array element is equal to searched number or not. Which is if(arr[i] == toSearch) then set found = 1 flag and terminate from loop. Since element is found no need to continue further. 6. Outside loop if(found == 1) then element is found otherwise not. The code is given below: #include <stdio.h> #define MAX_SIZE 100 // Maximum array size int main() { int arr[MAX_SIZE]; int size, i, toSearch, found; /* Input size of array */ printf("Enter size of array: "); scanf("%d", &size); /* Input elements of array */ printf("Enter elements in array: "); for(i=0; i<size; i++) { scanf("%d", &arr[i]); } printf("\nEnter element to search: "); scanf("%d", &toSearch); /* Assume that element does not exists in array */ found = 0; for(i=0; i<size; i++) { /* * If element is found in array then raise found flag * and terminate from loop. */ if(arr[i] == toSearch) { found = 1; break; } } /* * If element is not found in array */ if(found == 1) { printf("\n%d is found at position %d", toSearch, i + 1); } else { printf("\n%d is not found in the array", toSearch); } return 0; }

## Contact tutor

Send a message explaining your
needs and Geetika will reply soon.
Contact Geetika