Write a C function to search a number in the given list of
numbers. donot use printf and scanf
Answer Posted / 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 |
Post New Answer View All Answers
Why is c called a structured programming language?
Can a variable be both static and volatile in c?
How can I delete a file?
Why doesnt the call scanf work?
Explain how can you restore a redirected standard stream?
What is 'bus error'?
What is the benefit of using const for declaring constants?
Do you have any idea how to compare array with pointer in c?
Are there namespaces in c?
Why can’t constant values be used to define an array’s initial size?
What is the use of a semicolon (;) at the end of every program statement?
What is the use of header files?
What the different types of arrays in c?
Can we declare variables anywhere in c?
Can you write the algorithm for Queue?