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
What is string concatenation in c?
What is the use of function in c?
How can I run c program?
How do you initialize pointer variables?
What is the sizeof () operator?
What is malloc() function?
Describe the header file and its usage in c programming?
What do you mean by keywords in c?
What is a node in c?
What does calloc stand for?
Explain how can type-insensitive macros be created?
What are the advantages and disadvantages of pointers?
Can a pointer be static?
Explain is it better to bitshift a value than to multiply by 2?
What are the parts of c program?