
LANGUAGE: C++
CHALLENGE:
Given an int variable count that has already been declared , write a for loop that prints the integers 50 through 1, separated by spaces. Use no variables other than count.
SOLUTION:
for (count=50; count>0; count--){ cout << count << " "; }
THIS IS THE CODE FOR C:
for (count=50; count>0; count–){
printf(” %d”, count);
}
for (count=50; count>0; count–){
printf(“%d\n”,count);
}
for (count=50; count>0; count–)
{
System.out.println(count);
}
Java
for (int count=50; count>0; count–) {
System.out.print(count + ” ” );
}
This is all correct except the count- should be count–