ok, so i compiled this program- it has no errors.. but it keeps returning the first number i put in as a variable..
the assignment was to write a for loop that returns the product (number times a number) of two numbers.. so if i put in 5 and 3, it should return 15.. but instead it returns 5.
there was a catch to the assignment.. i could not use the multiplication operator.. and i had to use a for loop.. here is what i did.. it seems as if for some reason the for loop is just being ignored.. ugh.. :-/
Code:#include <stdio.h> int product(int x, int y){ int i; int result; for (i=0; i<y; i++) x += x; result= x; return result; } int main (){ int x, y; printf("Type a number"); scanf("%d", &x); printf("Type another number"); scanf("%d", &y); printf("%d", product(x,y)); return 0; }