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
How do you do dynamic memory allocation in C applications?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
How do you determine whether to use a stream function or a low-level function?
What is the difference between exit() and _exit() function?
What are the types of data files?
Is array name a pointer?
What are the benefits of organizational structure?
What is a dynamic array in c?
What are pointers? What are stacks and queues?
Explain what are the different data types in c?
When is a “switch” statement preferable over an “if” statement?
What are multibyte characters?
What are structure types in C?
explain how do you use macro?
what do the 'c' and 'v' in argc and argv stand for?