Multiplying Columns of Numbers in C Programming

In summary, the conversation discusses using a C program to multiply a column of numbers with a constant and the desired output format of the result. The speaker mentions using the %14.9lf format specifier and wanting the result to be displayed in scientific notation. They also recommend checking the documentation and suggest using either 'e' or 'g' in the format specifier.
  • #1
Rajini
621
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
  • #2
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.
 
  • #3
It's e. g uses the shorter of the e vs. f formats.
 

What is the purpose of multiplying columns of numbers in C programming?

The purpose of multiplying columns of numbers in C programming is to perform mathematical operations on a set of data to manipulate and analyze it in a more efficient manner.

How do you multiply columns of numbers in C programming?

To multiply columns of numbers in C programming, you can use the multiplication operator (*) or the math library function "mul()" to perform the multiplication. You will need to specify the variables or values to be multiplied and assign the result to a new variable.

What data types can be multiplied in C programming?

In C programming, integers (int) and floating-point numbers (float or double) can be multiplied. However, you should be cautious when multiplying floating-point numbers as they may result in rounding errors.

Can you multiply multiple columns of numbers at once in C programming?

Yes, you can multiply multiple columns of numbers at once in C programming. You will need to specify the variables or values for each column and use the multiplication operator (*) to perform the multiplication. Make sure to assign the result to a new variable or print it out for further use.

What are some common mistakes when multiplying columns of numbers in C programming?

Some common mistakes when multiplying columns of numbers in C programming include using the wrong data types, not assigning the result to a variable, and forgetting to include the multiplication operator (*). It is also essential to ensure that the correct variables or values are used for each column to avoid errors in the calculation.

Similar threads

  • Programming and Computer Science
Replies
22
Views
635
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
30
Views
4K
  • Programming and Computer Science
Replies
25
Views
1K
  • Programming and Computer Science
Replies
2
Views
945
  • Programming and Computer Science
Replies
7
Views
337
  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
Replies
19
Views
927
  • Programming and Computer Science
Replies
8
Views
1K
Back
Top