Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a C function to search a number in the given list of
numbers. donot use printf and scanf

Answer Posted / abdur rab

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

int main ( int argc, char* argv[] )
{
int array [ 10 ] = { 546, 541, 128, 1027, 1000,
10234, 657, 343, 111, 272 };
char _variable [ 50 ];
int _count = 0;
int _value = 0;

memset ( _variable, '\0', 50 );
puts ("Enter the number to search: ");
gets ( _variable );

_value = atoi ( _variable );

for ( _count = 0; _count < 10; _count++ ) {
if ( array [ _count ] == _value ) {
puts ("Search SUCCESSFUL");
return ( 0 );
}
}
puts ("Search NOT SUCCESSFUL");
return ( 1 );
}

If u guys really want to check the given input is numeric,
use isnumeric function defined in ctypes.h

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are qualifiers and modifiers c?

962


How does selection sort work in c?

1000


Differentiate between null and void pointers.

1137


What are the types of arrays in c?

1127


How is null defined in c?

1120


What is unsigned int in c?

958


Are pointers integers in c?

1042


What is scope of variable in c?

1011


What are the types of operators in c?

1030


Explain continue keyword in c

984


What are the advantages of using macro in c language?

1089


Which is better pointer or array?

993


Disadvantages of C language.

1067


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

1466


Give differences between - new and malloc() , delete and free() ?

1068