Multiplying Columns of Numbers in C Programming

Click For Summary
SUMMARY

The forum discussion focuses on formatting output in C programming, specifically when multiplying a column of numbers. The user successfully multiplies a number but encounters issues with displaying the result in scientific notation. The recommended solution involves using the 'e' format specifier in the printf function to achieve the desired output format. The discussion emphasizes the importance of understanding format specifiers in C, particularly for numerical output.

PREREQUISITES
  • Understanding of C programming syntax and structure
  • Familiarity with the printf function and its format specifiers
  • Basic knowledge of floating-point arithmetic in C
  • Experience with debugging and testing C programs
NEXT STEPS
  • Research C programming format specifiers, focusing on 'e', 'f', and 'g'
  • Explore advanced formatting options in the printf function
  • Learn about floating-point precision and representation in C
  • Investigate common pitfalls in numerical output formatting in C
USEFUL FOR

C programmers, software developers, and students learning about numerical output formatting in C. This discussion is particularly beneficial for those looking to enhance their skills in displaying floating-point numbers accurately.

Rajini
Messages
619
Reaction score
4
Hello all,

I wrote a C program to multiply a column of numbers (for eg., number will look like this 10.45618) with some constant...
after multiplication i get the correct value (i tested using calculator).
Now the output is 0.00005672 (i use %14.9lf) ..but i want them to display like this: 5.672E or D-5.
E stands for 10.
thanks for your help.
 
Technology news on Phys.org
Check the documentation on format specifiers for printf. There are a lot of useful options, it would be good to know what's possible and know where to look things up -- so go googling!

I think for your particular issue, you want 'e' or 'g' instead of 'f'; I don't remember which one.
 
It's e. g uses the shorter of the e vs. f formats.
 

Similar threads

  • · Replies 28 ·
Replies
28
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 30 ·
2
Replies
30
Views
7K
Replies
14
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 19 ·
Replies
19
Views
2K