It looks like maybe you are modeling from some outdated templates. I thought it might be worth offering how I might write this problem today:

"PGstandard.pl", #loads four macros you loaded

"MathObjects.pl", #almost always best practice

"contextIntegerFunctions.pl",

"PGML.pl", #my preference; easier for

#future users to work with

"PGcourse.pl", #allow yourself and future

#users to make course-wide

#customizations by editing this

TEXT(beginproblem()); #somewhere I heard it's better

#to cease using & and use ()

#instead; can't recall why

$a = non_zero_random(-6,6,2);

$b = non_zero_random(-6,6,2);

$e = $c+$d;

Context("IntegerFunctions");

$ans = Real("($a)^($c) ($b)^($d) C($e,$d)");

#makes $ans a MathObject Real, which among other

#things will enable special feedback messages to

#certain incorrect answers automatically;

#by using quotes, you pass a string instead of a

#perl real, and you can use ^ instead of **;

#the parens are needed in the bases, probably

#extraneous for the exponents

Context()->variables->add(y=>'Real');

$f=Formula("($a x + $b y)^($e)")->reduce;

#in case $a or $b is -1, 0, or 1; which is not #possible with your randomization, but this

#is generally helpful

$term=Formula("x^($c)y^($d)")->reduce;

#PGML feels cleaner to me and easier for a future

#person to work with; also you get the answer

#evaluation right next to the answer blank

What is the coefficient of [`[$term]`] in the expansion of [`[$f]`]?