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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you do dynamic memory allocation in C applications?

624


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1646


How do you determine whether to use a stream function or a low-level function?

636


What is the difference between exit() and _exit() function?

595


What are the types of data files?

719






Is array name a pointer?

598


What are the benefits of organizational structure?

564


What is a dynamic array in c?

587


What are pointers? What are stacks and queues?

573


Explain what are the different data types in c?

746


When is a “switch” statement preferable over an “if” statement?

639


What are multibyte characters?

639


What are structure types in C?

656


explain how do you use macro?

662


what do the 'c' and 'v' in argc and argv stand for?

638