8 Mar 2013

grapline level-2 solved


/*
 solution to grapline online change level-2

*\



#include<stdio.h>
#include<conio.h>
int checkprime(int );
void main()
{long int n=514230,i,sum=0;
for(i=2;i<n-1;i++)
    {if(checkprime(i)!=0 && n%i==0)
        {printf("\n%ld",i);
            {sum=sum+i;}
        }
    }
printf("OUTPUT:%ld",sum);
getch();
}

int checkprime(int i)
{for(int j=2;j<i;j++)
    {if(i%j==0)
        {return 0;}
    }
if(i==j)
return 1;
}

Categories: ,

Related Posts:

  • Words Count in String /* Program to count the no. of words in a string.... */ #include<iostream.h>#include<conio.h>#include<stdio.h>void main(){clrscr();char a[50];int i,j,c=1;cout<<"Enter the string:";gets(a);for(i=0;… Read More
  • Command Line arguments //Command Line Arguments   #include <stdio.h> int main ( int argc, char *argv[] ) { if ( argc != 2 ) /* argc should be 2 for correct execution */ { /* We print argv[0] assuming it is the program … Read More
  • Trailing Zeroes /* Given a number find the number of trailing zeroes in its factorial. Input Format A single integer - N Output Format Print a single integer which is the number of trailing zeroes. Input Constraints 1… Read More
  • Clock angle problem /* Find minimum angle between hour and minute hand.  Input: The first line contains the number of test cases, T. T lines follow, each of which contains two integer Hour hand H and minute hand M . Output: … Read More
  • Insertion and Quick Sort /*  A program to sort a range of numbers with Insertion and Quicksort, check their sorting time and prompt the result on the screen */#include <stdio.h>#include <iostream.h>#include <stdlib.h>#inclu… Read More

0 comments:

Post a Comment

Copyright © 2025 UPgradeCODING | Powered by Blogger