New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Anyone can tell me what is wrong with that code please?
#include<stdio.h> int main(void) { int a[9]; int i; printf("input:\n"); for (i = 0; i <= 8; i++) { scanf("%d", &a[i]); } for (i = 0; i <= 8; i = i + 3) { printf("output:\n"); printf("%d , %d, %d \n", a[i], a[i + 1], a[i + 2]); return 0; } }
3 Answers
+ 2
You are returning 0 inside the second loop, so it is terminated in the first run.
0
Write a program that reads nine integers and prints them three in a line separated by commas as shown below.
Input:
10 31 2 73 24 65 6 87 18
Output
10, 31, 2
73, 24, 65
6, 87, 18
0
Moritz Vogel thank you so much.