#### Search results for long

##### Example:[1]
``````
Write a C program function to convert Decimal to Binary number system.
``````
``````
#include <stdio.h>
long binary(long int n);
int main()
{
long int num = 29;
long res;
res = binary(num);
printf("Result in binary is %d\n",res);
return 0;
}
long binary(long int n)
{
long rem,a = 1,bin = 0;
while(n > 0)
{
rem = n%2;
bin = bin + rem *a;
n /= 2;
a *= 10;
}
return bin;
}

``````
##### Example:[2]
``````
Write a C program to find longest sequence of elements in an array.
``````
``````
#include <stdio.h>
int result = 0,f_result = 0;
unsigned int find_long(int a[]);
int main()
{
int aa[] = {0,2,3,8,9,10,11,12,18,19,20,21,22,23,24};
unsigned int lon;
lon = find_long(aa);
printf("The Long sequence is %d\n",lon);
return 0;
}
unsigned int find_long(int a[])
{
int len = 15;
unsigned int i;
for(i = 1;i < len;i++)
{
if((a[i] - a[i-1]) == 1)
{
result++;
if(result >= f_result)
{
f_result = result;
printf("f_result is %d\n",f_result);
}
}else
{
result = 0;
printf("result is %d\n",result);
}
}
return f_result+1;
}

``````
##### Example:[3]
``````
Write a program to find the number of times that a given word(i.e. a short string) occurs in a sentence (i.e. a long string!).
``````
``````
#include <stdio.h>
#include <string.h>
unsigned int search_word(char *,char *);
int main()
{
char *s_str = "the";
char *l_str = "the word searching for from these sentence is the.";
unsigned int result;
result = search_word(s_str,l_str);
printf("Small string is found %d times in long string\n",result);
return 0;
}
unsigned int search_word(char *s1,char *s2)
{
int times = 0;
int i = 0,j = 0,k = 0;
int size = strlen(s1);
printf("Size of small string \" %s \" is: %d\n",s1,size);
while(s2[j] != '\0')
{
if(j >= (size - 1))
{
if(s2[j] == s1[size-1] && s2[j-1] == s1[size-2] && s2[j-2] == s1[size-3])
{
times = times + 1;
}
}
j++;
}
return times;
}
``````

 Search more C examples Search more C MCQs

#### Popular C search examples

 goto function pointer unsigned signed stack overflow else fscanf union void switch double int for typedef sizeof factorial state machine auto while fibonacci