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


Please Help Members By Posting Answers For Below Questions

What is self-referential structure in c programming?

653


Is javascript based on c?

591


What is the difference between mpi and openmp?

727


How can you find the exact size of a data type in c?

595


hi folks i m approching for h1 b interview on monday 8th of august at montreal and i m having little problem in my approval notice abt my bithdate my employer has made a mistake while applying it is 12th january and istead of that he had done 18 the of january do any body have any solution for that if yes how can i prove my visa officer abt my real birthdate it urgent please let me know guys thaks dipesh patel

1406






What is operator promotion?

623


How many identifiers are there in c?

576


What is static volatile in c?

572


What is #line?

605


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

684


Explain output of printf("Hello World"-'A'+'B'); ?

969


can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

1400


Explain the process of converting a Tree into a Binary Tree.

2094


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

3118


How can you tell whether a program was compiled using c versus c++?

614