What's wrong here is that your logic is saying 5 < 5, which is false. Your for loop is not executing because when your printloop function is invoked at printloop(5); it is passing the integer value of 5.
void printloop (int valx) {
int x;
for (x = valx; x < 5; x++) {
printf("Value of x is: %d\n", x);
}
Your printloop function is receiving a value of 5, setting x inside of your function to x = 5.
When it is time for your for loop to execute you will have
void printloop (int valx) {
int x = 5;
for (5 = valx; 5 < 5; 5++) {
printf("Value of x is: %d\n", x);
}
}
the for loop will see 5 < 5, which is false, and thus the loop will not execute.
I think what you want to say is
#include <stdio.h>
void printloop (int valx) {
int x;
for (x = 0; x < valx; x++) {
printf("Value of x is: %d\n", x);
}
}
int main() {
printloop(5);
return 0;
}
Which will output:
Value of x is: 0
Value of x is: 1
Value of x is: 2
Value of x is: 3
Value of x is: 4
I hope this makes sense, and keep up the good work!
5 < 5is false. What is your problem?