Hi everyone,
Some questions in my previous post is still left unanswered.
Here it is again:

How can i accept decimal numbers from STDIN and perform arithmetic operations on it in C.

How can i create a subroutine within a program, that can be called again & again at different part of a program.
THANKS :mrgreen:

Hi everyone,
I not very clear what you are talking about.

Receving decimal numbers???

Do you mean returning decimal numbers from a function

declare a variable as float
float a;
a = rew( ); // Is this what you mean

As for your other question

You cannot call a function within its own function.
You can declare the function externally being public or private
and call it
if there is arguments and a return value
a = gow(c,d); // Is this what you mean

if it has no arguments or any return values

gow(); //Is this what you mean

I really hope this helps you

Yours Sincerely

Richard West

For reading you use scanf() with format specifier "%f","%g","%e" or printf();
the variable tyoe is float and functions are in math.h

You need functions->read tutorials

OK, let me clear things up, suppose i want to enter 23.45 using SCANF, the program will only accept the 23 and use the .45 for the other SCANF, how can i avoid it.

First, avoid scanf. Second, use a floating point type to enter a floating point value.

#include <stdio.h>
  
  int main()
  {
     double number;
     fputs("Enter number: ", stdout);
     fflush(stdout);
     if ( scanf("%lf", &number) == 1)
     {
  	  printf("number = %g\n", number);
     }
     return 0;
  }
  
  /* my output
  Enter number: 23.45
  number = 23.45
  */
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.