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 in c language?
Explain what is the purpose of "extern" keyword in a function declaration?
What does %d do?
What is the g value paradox?
What is the heap?
Why string is used in c?
What are the functions to open and close the file in c language?
Why we use break in c?
How do you construct an increment statement or decrement statement in C?
How do I read the arrow keys? What about function keys?
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
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)
What is static function in c?
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
Is fortran still used in 2018?