Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

runtime error(SIGSEGV) in byteland coins ques. Please help.

$
0
0

The following program is showing runtime error(SIGSEGV). Please help me to fix this.

#include<stdio.h>
int main()
{
int i=10;
int n;
while(i--)
{
    scanf("%d",&n);
    printf("%d\n",calc(n));
}
return 0;
}
int calc(int x)
{
  if(((x%2)+(x%3)+(x%4))==0)
{
    return (calc(x/2)+calc(x/3)+calc(x/4));
}
return x;
}

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>