As you've given it here, I'm surprised the second one executed: at all: there is no closing brace to terminate the main) function. Try one of the following;
Code:
#include <stdio.h>
main () {
printf("This program will do some computations\n");
printf("The two numbers I am using in this program are 63 and 25.\n");
{
int sum;
int num1 = 63;
int num2 = 25;
sum = num1 + num2; // addition
printf("Sum is %d\n", sum); // print the result
}
return 0; // return statement AFTER you compute the sum
}
or (if you want to do it with functions);
Code:
#include <stdio.h>
void myfunction();
main () {
printf("This program will do some computations\n");
printf("The two numbers I am using in this program are 63 and 25.\n");
myfunction()
return 0;
}
void myfunction()
{
int sum;
int num1 = 63;
int num2 = 25;
sum = num1 + num2; // addition
printf("Sum is %d\n", sum); // print the result
}
As a general rule, code placed in a function after a return statement does not get executed. And the compiler doesn't magically decide that, since you're computing a sum, that it needs to print the result.
Unrelated to your problem: the // style of comment is fairly recent, and is only supported in C++ compilers (reasonably common) or C compilers compliant with the 1999 C standard (relatively rare). C compilers that comply with the 1989 C standard will choke on such comments.