## How to use prime number is not prime in c language

### program to use prime number is not prime in c language

``````
#include <stdio.h>
#include <math.h>
int main()
{
int i, n;
printf("Enter a number : ");
scanf("%d", &n);
for (i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
{
break;
}
printf("i=%d\n", i);
printf("n=%d\n", n);
}
if (i > sqrt(n))
{
printf("%d is prime\n", n);
}
else
{
printf("%d is not prime\n", n);
}
return 0;
}
``````
``` ```

### output

``````
Enter a number : 7
i=2
n=7
7 is prime
``````

### output

``````
Enter a number : 4
4 is not prime
``````

## How to use sum and average in c language

### program to use sum and average in c language

``````
#include<stdio.h>
int main()
{
int i=1,n,sum=0;
float avg;
printf("Enter 10 positive numbers : \n");
while(i<=10)
{
printf("Enter number %d : ",i);
scanf("%d",&n);
if(n<0)
{
printf("enter only positive numbers\n");
continue;
}
sum+=n;
i++;
}
avg=sum/10.0;
printf("sum=%d avg=%f\n",sum,avg);
return 0;
}
``````
``` ```

### output

``````
Enter 10 positive numbers :
Enter number 1 : 2
Enter number 2 : 4
Enter number 3 : 5
Enter number 4 : 6
Enter number 5 : 9
Enter number 6 : 4
Enter number 7 : 3
Enter number 8 : 1
Enter number 9 : 8
Enter number 10 : 5
sum=47 avg=4.700000
``````