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
Can you mix old-style and new-style function syntax?
What does a function declared as pascal do differently?
What is ## preprocessor operator in c?
How can you tell whether two strings are the same?
What is the use of getchar() function?
What is variable declaration and definition in c?
What are void pointers in c?
provide an example of the Group by clause, when would you use this clause
How many header files are in c?
What is the most efficient way to count the number of bits which are set in an integer?
What is the use of bitwise operator?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
Why does notstrcat(string, "!");Work?
Is this program statement valid? INT = 10.50;
Where we use clrscr in c?