-2

I'm trying to get my program to repeat the letter "a" 255 times, but for some reason this prints "a" just once and then stops.

#include <stdio.h>
int main(){
    for(int e = 0; e < 253; e++);
    {
        printf("a");
    }
    printf("\n");
    return 0;
}
Wasi Ahmad
  • 35,739
  • 32
  • 114
  • 161
kouta-kun
  • 169
  • 4

2 Answers2

2

This is how you should do it.

#include <stdio.h>
int main(){
    for(int e = 0; e < 253; e++)
    {
            printf("a");
    }
    printf("\n");
    return 0;
}
Vimbuddy
  • 166
  • 3
  • 19
2

There is a semicolon end of this loop for(int e = 0; e < 253; e++);. The for loop just runs without doing anything. Finally the rest of the statement gets executed and you get only one print.

haasi84
  • 104
  • 3