Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Write a C function to search a number in the given list of
numbers. donot use printf and scanf

Answers were Sorted based on User's Feedback



Write a C function to search a number in the given list of numbers. donot use printf and scanf..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
char a[]="enter the no. of terms tou are going to enter :";
char a1[100];
char n;
puts(a);
int flag=0;
n=getchar();
int n1;
n1=(int)n /* type casting*/
for(int i=0;i<n1;i++)
{
a[i]=getchar();
}
char a3[]="enter the number do you want to find :";
puts(a3);
char s;
s=getchar();
int b=(int)s;
for(i=0;i<n1;i++)
{
if(b==(int)a[i])
flag=1;
}
if(flag==1)
printf("number is found");
else
printf("not found");
getch();
}
this was the logic suddenly striked me.......................

Is This Answer Correct ?    5 Yes 0 No

Write a C function to search a number in the given list of numbers. donot use printf and scanf..

Answer / 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

Write a C function to search a number in the given list of numbers. donot use printf and scanf..

Answer / gg

Dear... Vignesh... r u tested?
if tested..., on what Compiler...

Is This Answer Correct ?    2 Yes 0 No

Write a C function to search a number in the given list of numbers. donot use printf and scanf..

Answer / vignesh1988i

ya..... sorry... it wont work... since getchar gets only one
character the time.... when we give 48... i will take 4 and
8 .. but not as 48.... sorry for posting it... a lesson i
have learnt

Is This Answer Correct ?    1 Yes 0 No

Write a C function to search a number in the given list of numbers. donot use printf and scanf..

Answer / abdur

sorry for the wrong information use isdigit(char)

Is This Answer Correct ?    1 Yes 0 No

Write a C function to search a number in the given list of numbers. donot use printf and scanf..

Answer / vignesh1988i

very sorry yaar/.... i forgettenly used printf statements in
my before posts.......... i think this can be the logic...
if am not wrong..............

#include<stdio.h>
#include<conio.h>
void main()
{
char a[]="enter the no. of terms tou are going to enter :";
char a1[100];
char n;
puts(a);
int flag=0;
n=getchar();
int n1;
n1=(int)n /* type casting*/
for(int i=0;i<n1;i++)
{
a[i]=getchar();
}
char a3[]="enter the number do you want to find :";
puts(a3);
char s;
s=getchar();
int b=(int)s;
for(i=0;i<n1;i++)
{
if(b==(int)a[i])
flag=1;
}
if(flag==1)
{
char q[]="number is found";
puts(q);
}
else
{
char w[]="number not found";
puts(w);
}
getch();
}

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More C Interview Questions

How can I make a program in c to print 'Hello' without using semicolon in the code?

9 Answers   C DAC, Practical Viva Questions,


What are the two types of structure?

0 Answers  


What is the proper way of these job Tell me about there full work

0 Answers   EDS,


What is Lazy evaluation in C? Give an example.

1 Answers  


What is memmove?

1 Answers   Oracle,


An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode

0 Answers  


what is the answer for it main() { int i; clrscr(); printf("%d",&i)+1; scanf("%d",i)-1; }

3 Answers  


what is ans for this scanf(%%d",c);

1 Answers  


What does dm mean sexually?

0 Answers  


What does the error 'Null Pointer Assignment' mean and what causes this error?

0 Answers   TISL,


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

0 Answers   Genpact,


Under what circumstances does a name clash occur?

0 Answers   InterGraph,


Categories