A little question about c language

AI Thread Summary
The discussion centers on a coding issue in a C program where the output of an array is showing random numbers instead of the expected initialized values. The primary problem identified is a syntax error in the printf statement, specifically the missing closing parenthesis. Once this error is corrected, the program should function as intended, displaying the initialized values of the array. The user expresses gratitude for the assistance in identifying the error.
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
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top