Introduction
C Programming
C Advanced
Important C Programs
Modal Box
Tutorials
C is a very powerful and widely used language. It is used in many scientific programming situations. It forms (or is the basis for) the core of the modern languages Java and C++. It allows you access to the bare bones of your computer.C++ is used for operating systems, games, embedded software, autonomous cars and medical technology, as well as many other applications. Don't forget to visit this section...
Searching
Searching is the process to find if the number to be searched by user exists in the given array or not.
Types of searching are ;
1. Linear Searching
2. Binary Searching
Here we will discuss only Linear search.
Program to search an element in the given array
#include <stdio.h> #include <conio.h> void main() { int a[10], i=0, ele=0, flag=0; printf("enter array elements"); for(i=0; i<10; i++) { scanf("%d", &a[i]); } printf("enter the element to search"); scanf("%d", &ele);
// logic to find the element in the given array. for(i=0; i<10; i++) { if(a[i]==ele) { flag=1; break; } }
if(flag==1) printf("element found"); else printf("element not found"); }
Video/ C Introduction
Watch video in full size