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
What is a program flowchart and explain how does it help in writing a program?
Explain what are run-time errors?
What is a program flowchart and how does it help in writing a program?
Explain threaded binary trees?
praagnovation
What is this infamous null pointer, anyway?
What is d'n in c?
which is an algorithm for sorting in a growing Lexicographic order
How do I get a null pointer in my programs?
Is flag a keyword in c?
How can I avoid the abort, retry, fail messages?
What is assert and when would I use it?
How do I swap bytes?
can we change the default calling convention in c if yes than how.........?
Explain what is a static function?