Anyone can tell me what is wrong with that code please? | Sololearn: Learn to code for FREE!
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; } }

11th Sep 2018, 4:03 PM
Search For Selligoods on Google
Search For Selligoods on Google - avatar
3 Answers
+ 2
You are returning 0 inside the second loop, so it is terminated in the first run.
11th Sep 2018, 5:39 PM
Moritz Vogel
Moritz Vogel - avatar
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
11th Sep 2018, 4:04 PM
Search For Selligoods on Google
Search For Selligoods on Google - avatar
0
Moritz Vogel thank you so much.
12th Sep 2018, 12:11 AM
Search For Selligoods on Google
Search For Selligoods on Google - avatar