A little question about c language

Click For Summary

Discussion Overview

The discussion revolves around a coding issue in C language, specifically regarding the initialization and printing of an array. Participants are examining a code snippet that produces unexpected output.

Discussion Character

  • Technical explanation

Main Points Raised

  • One participant presents a code snippet that initializes an array but reports that it outputs random numbers.
  • Another participant identifies a potential issue with the printf statement, noting the absence of a closing parenthesis.
  • A subsequent participant acknowledges finding the error, suggesting that they have resolved the issue.
  • Another reply reiterates the problem with the printf statement, thanking the previous contributor for their input.

Areas of Agreement / Disagreement

Participants appear to agree on the identification of the error related to the printf statement, but the discussion does not reach a consensus on the overall implications of the code's behavior.

Contextual Notes

There may be limitations in understanding the full context of the problem, as the discussion does not explore the implications of the random output further or clarify the expected behavior of the code.

nenyan
Messages
67
Reaction score
0
#include <stdio.h>
#include <stdlib.h>
int main()
{ double a[10];
int i=0;
for(i=0;i<10;i++)
a=0.0;
for(i=0;i<10;i++)
printf("a[%d]=%e, "), i, a;}

The result is radom number. What's wrong with my code?
 
Technology news on Phys.org
nenyan said:
The result is radom number. What's wrong with my code?
The problem is here:
printf("a[%d]=%e, "), i, a;


Where is the closing parenthesis on the printf statement?
 
ok,,,i found the error
 
D H said:
The problem is here:

Where is the closing parenthesis on the printf statement?

Thanks a lot
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
7
Views
2K
Replies
14
Views
4K
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
6K