This code worked perfectly at school in the lab but when I copied it to notepad and sent it to myself via email and pasted the code into Dec-C++ it no longer worked. When I run the program it should allow me to type a number such as four and give me an answer (in this case six). Instead of working and giving me the correct answer when i type in the number and press enter the command prompt window closes. I tried to fix it last night but I am not sure what could be wrong.
Code:#include <stdio.h> int sum(int n) { if(n==0) return(0); else return(sum(n-2)+n); } main() { int N; scanf("%d",&N); printf("The sum is %d.\n", sum(N)); }