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 is string in c language?

1130


Explain what is the purpose of "extern" keyword in a function declaration?

1056


What does %d do?

1256


What is the g value paradox?

1152


What is the heap?

1209


Why string is used in c?

991


What are the functions to open and close the file in c language?

1021


Why we use break in c?

988


How do you construct an increment statement or decrement statement in C?

1211


How do I read the arrow keys? What about function keys?

1064


Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

3522


Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

2281


What is static function in c?

1103


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

1057


Is fortran still used in 2018?

1025