### Function Programming : Divisible by 5 in C

Write a C Program using function to check whether the given input is divisible by 5 or not.

Source Code in C:

#include<stdio.h>
void divis (int p, int q);
int main()
{
int a, b=5;
scanf("%d", &a);
divis(a, b);
}

void divis (int p, int q)
{
if (p%q = =0)
printf ("\n Given number is divisible by 5");
else
printf ("\n Given number is not divisible by 5");
}

### Function Programming : Print Array in C

Write a C Program to print all elements from an Array using c-function.

#include<stdio.h>
void array(int b[], int n);
int main( )
{
int n, j;
printf("\nThe size of array is : ");
scanf("%d", &n);
int a[n];
for(j=0; j<n; j++)
scanf("%d", &a[j]);
array(a, n);
}

void array(int b[],int n)
{
int i;
for(i=0; i<n; i++)
{
printf("  %d", b[i]);
}
}

### Function Programming : Array programming in C

Write  a program using c-function to read from an array and do the sum of all elements from that array.

Source Code in C:

#include<stdio.h>
int arr(int a[], int len);
int main()
{
int len, ret, i;
printf ("\nEnter your array size: ");
scanf ("%d", &len);
int a[len];
ret=arr(a, len);
printf("\nThe sum is: %d", ret);
}

int arr(int b[ ], int n)
{
int i, result =0;
for(i=0; i<n; i++)
{
scanf ("%d", &b[i]);
result += b[i];
}
for(i=0; i<n; i++)
result +=  b[i];

return (result);
}

### Function Programming in C : Prob-5

Evaluate below equation using c function.

sum=x + x^2  +  x^3  + ...........+ x ^ n.

Source Code in C:

#include<stdio.h>
int main()
{
int a;
scanf("%d",&a);
sum(a);
}

int sum(int b)
{
int i,c=1,sum=0;
for(i=1; i<=5; i++)
{
c=b*i;
sum+=c;
}

printf("\nThe sum is: %d", sum);
}

### Function Programming : Even and Odd Number find using C

WAP using C-Function to check Odd Number and Even Number from a given input.

#include<stdio.h>
int evenodd(int a);
int main()
{
int a;
printf("\nEnter the number: ");
scanf("%d",&a);
evenodd(a);
}
int evenodd(int q)
{
if  (q%2 = = 0)
printf("\nThis is a even number");
else if (q%2 = = 1)
printf("\nThis is a odd number");
}

### Function Programming : Strange Number in C

WAP to check whether the given input is Strange or Not.

#include<stdio.h>
int main()
{
int digit;
scanf("%d", &digit);
strng(digit);
}

int strng(int d)
{
int i, j, t=1;
while (d!=0)
{
j=d%10;
d=d/10;
for (i=2; i<j; i++)
{
if ( j%i = =0 )
{
t=0;
break;
}
}
}

if (t = = 1)
printf("\nThis number is strange");
else
printf("\nThis number is not strange");
}

### Function Programming : Perfect Number in C

WAP using C-Function to check whether the given number is Perfect or Not.

#include<stdio.h>
int main()
{
int i;
scanf("%d",&i);
checkperfect(i);
}

int checkperfect(int j)
{
int a,sum=0;
for(a=1;a<=j/2;a++)
{
if (j%a = = 0)
sum+=a ;
}

if(sum = = j)
printf("\n Perfect Number \n");
else
printf("\n Not Perfect Number \n");
}

### Function Programming : Check Prime in C

Write a Program to check whether the given input in Prime or Not . User defined function is mandatory to use.

Source Code in C Language:

#include<stdio.h>
int main()
{
int inp;
scanf("%d",&inp);
printf("\nThis number is: ");
pri(inp);
}
int pri(int p)
{
int i,t;
t=1;
for(i=2; i<p; i++)
{
if(p%i==0)
{
t=0;
break;
}
}

if(t==0)
printf("Not prime");
else
printf("Prime");
}