Declaration statements in C -
Declaration statements in C -
i seem have problem declarations screwing math. advice or suggestions highly welcomed.
here's code:
int num1, num2, num3, num4, op, ; op = ((1==num3) || (2==num4)); num3 = (num1 + num2); num4 = (num1 * num2);
i've been trying lots of arrangements , re-assignments. lot has compiled, when 5 + 5 = 2659043, there's problem...
not sure you're trying do, code doing:
int num1, num2, num3, num4, op, ;
this line informs c compiler needs allocate space 5 integers (num1, num2, num3, num4, op), these integers can used variables until scope expires. not sure why have lastly ',' might want remove that.
op = ((1==num3) || (2==num4));
if num3 1, or num4 = 2, set op 1 (true). otherwise, set op 0 (false).
num3 = (num1 + num2);
self-explanatory: add together num1 , num2 , set sum num3.
num4 = (num1 * num2);
self explanatory: multiply num1 , num2 , set product num4.
immediately see issue program. using these variables, have not initialized them anything. example, how there supposed sum of (num1 + num2) if num1 , num2 not have value. seek this:
#include <stdio.h> int main() { int num1, num2, sum; num1 = 1; num2 = 2; sum = num1 + num2; printf("sum = %d\n", sum); }
c declaration
Comments
Post a Comment