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
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
what are the facialities provided by you after the selection of the student.
How would you obtain the current time and difference between two times?
What does c mean in basketball?
What is the use of static variable in c?
What does == mean in texting?
How do I copy files?
What is nested structure with example?
What is the ANSI C Standard?
Write a program to check armstrong number in c?
Difference between Function to pointer and pointer to function
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
What are different storage class specifiers in c?
Explain how are 16- and 32-bit numbers stored?
What is the difference between near, far and huge pointers?