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 to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
What is the use of getchar() function?
Can we assign string to char pointer?
What is string constants?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
Which is better pointer or array?
What is a 'null pointer assignment' error?
What is string function in c?
Why do we need arrays in c?
Why do we need volatile in c?
shorting algorithmS
How are 16- and 32-bit numbers stored?
Which built-in library function can be used to match a patter from the string?
Why do we use stdio h and conio h?
Can you please explain the difference between syntax vs logical error?