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

Why doesn't C support function overloading?

2618


How do you determine a file’s attributes?

1019


What type of function is main ()?

999


what is recursion in C

1023


How is a macro different from a function?

1121


Is it possible to execute code even after the program exits the main() function?

1283


What do you mean by keywords in c?

1086


What is dynamic memory allocation?

1287


Can we change the value of constant variable in c?

1008


What is time null in c?

1010


How can you read a directory in a C program?

1096


What is static volatile in c?

977


What is the best organizational structure?

1068


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3187


Should a function contain a return statement if it does not return a value?

1024