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 self-referential structure in c programming?
Is javascript based on c?
What is the difference between mpi and openmp?
How can you find the exact size of a data type in c?
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
What is operator promotion?
How many identifiers are there in c?
What is static volatile in c?
What is #line?
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)
Explain output of printf("Hello World"-'A'+'B'); ?
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......
Explain the process of converting a Tree into a Binary Tree.
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
How can you tell whether a program was compiled using c versus c++?