input - Simple cube and square sum function won't run (C) -
learning c, trying code program outputs sum of cube , square of inputted number.
#include <stdio.h> main() { int a; scanf("%d",a); printf("%d",cube(a)+sqr(a)); } cube(int x) { return(x*x*x); } sqr(int arg) { return(arg*arg); }
when run program outputs seemingly random string of numbers after input number. way fix without changing usage of returns assign variables?
scanf
needs pointer:
scanf("%d",&a);
instead of
scanf("%d",a);
Comments
Post a Comment