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
Why doesn't C support function overloading?
How do you determine a file’s attributes?
What type of function is main ()?
what is recursion in C
How is a macro different from a function?
Is it possible to execute code even after the program exits the main() function?
What do you mean by keywords in c?
What is dynamic memory allocation?
Can we change the value of constant variable in c?
What is time null in c?
How can you read a directory in a C program?
What is static volatile in c?
What is the best organizational structure?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
Should a function contain a return statement if it does not return a value?