Sunday 15 February 2015

c program for multiplication

c program two add two numbers

#include<stdio.h>
#include<math.h>
void main()
{
    int a[1000]={2,3},i,j=2,n;
    printf("enter the upper range of prime numbers \n");
    scanf("%d",&n);
    for(i=3;i<=n;i+=2)
    {   
        count=0;
        for(j=1;j<=sqrt(i);j++)
        {
            if(i%a[j]==0)
            {
                    count=-1;
                    continue;
            }
       
        }
        if(count!=-1)
        {
            printf("%d,",i);
            a[++j]=i;
        }
    }
   
}