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
How do you define a string?
Can include files be nested? How many levels deep can include files be nested?
Why do we need functions in c?
What is nested structure in c?
Is that possible to add pointers to each other?
What is the difference between printf and scanf )?
What is non linear data structure in c?
What does calloc stand for?
What is the benefit of using const for declaring constants?
What is an endless loop?
Difference between linking and loading?
What will be the outcome of the following conditional statement if the value of variable s is 10?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
What is variable initialization and why is it important?
What are the loops in c?