c++ programs for practice

Here you can find sample and simple c++ programs that are helpful for computer science students

Pages

  • Home
  • About Me
  • Share Your Programs
Showing posts with label linear search. Show all posts
Showing posts with label linear search. Show all posts

Friday, August 2, 2013

Program to search element in an array - Linear search

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int n,p=-1;
char a[100],s;
cout<<"Enter the line of text : ";
gets(a);
cout<<"Enter the character to be searched : ";
cin>>s;
for(int i=0;a[i]!='\0';++i)
if(a[i]==s)
p=i;
if(p>=0)
cout<<"Character found in "<<p<<"th position";
else
cout<<"Character not found ";
getch();
}
Posted by Athul KV at 7:45 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: for loop, if-else, linear search, loop
Older Posts Home
Subscribe to: Posts (Atom)

Popular Posts

  • Program for multiplication of matrix using " class "
  • Program to enter your height in centimeters and convert into feet and inches
  • Program for Newton's Law of Gravitation
  • Program To Find Out The Final Velocity Of A Body Using Linear Motion Equation
  • Program to display all prime numbers less than 100
  • Program to accept 20 numbers and display it in ascending order and descending order - Bubble sort
  • Program to find out Economic Order Quantity (EOQ)
  • Program to find the sum of all the elements of a matrix
  • Program to find out the volume of cone
  • Program to print the sum of first n natural numbers using " while loop "

About Me

My photo
Athul KV
View my complete profile

Labels

  • array (4)
  • bubble sort (1)
  • class (1)
  • conditional operator (1)
  • do-while loop (1)
  • for loop (21)
  • function (3)
  • if-else (10)
  • linear search (1)
  • loop (10)
  • mathematical calculations (19)
  • matrix (4)
  • nested loop (8)
  • new and delete operators (1)
  • pointer (1)
  • string (3)
  • switch (1)
  • two dimensional array (5)
  • while loop (4)

Facebook Fans

Blog Archive

  • ▼  2014 (1)
    • ▼  December (1)
      • Program To Find Out The Final Velocity Of A Body U...
  • ►  2013 (44)
    • ►  November (1)
    • ►  October (2)
    • ►  August (6)
    • ►  July (35)

Contact Form

Name

Email *

Message *

Total Pageviews

c++ programs for practice Donot Copy. Powered by Blogger.