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 are qualifiers and modifiers c?
How does selection sort work in c?
Differentiate between null and void pointers.
What are the types of arrays in c?
How is null defined in c?
What is unsigned int in c?
Are pointers integers in c?
What is scope of variable in c?
What are the types of operators in c?
Explain continue keyword in c
What are the advantages of using macro in c language?
Which is better pointer or array?
Disadvantages of C language.
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
Give differences between - new and malloc() , delete and free() ?