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
What is the purpose of macro in C language?
What is function prototype in c language?
What does %p mean c?
How do I use void main?
Explain why can’t constant values be used to define an array’s initial size?
What is self-referential structure in c programming?
What is selection sort in c?
Why does this code crash?
Explain what is the difference between functions getch() and getche()?
Explain what is a pragma?
How reliable are floating-point comparisons?
What are the functions to open and close the file in c language?
The __________ attribute is used to announce variables based on definitions of columns in a table?
What is memcpy() function?
What is a node in c?