| | |
Decimal Problem In C
![]() |
•
•
Join Date: Aug 2004
Posts: 140
Reputation:
Solved Threads: 2
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:
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:
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
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
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
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
*/ "One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- Decimal problem (MySQL)
- binary to decimal problem (C++)
- Hi Everyone, Have a C++ Problem. (C++)
- Need Help Revising Array program: Visual C++ (C++)
Other Threads in the C Forum
- Previous Thread: Array in talbe (problem)
- Next Thread: Network Applications
| Thread Tools | Search this Thread |
* ansi api array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile createcopyoffile createprocess() directory dynamic execv fflush file floatingpointvalidation fork forloop frequency function getlasterror getlogicaldrivestrin givemetehcodez grade graphics gtkgcurlcompiling gtkwinlinux hardware highest histogram homework i/o ide inches include infiniteloop initialization input intmain() iso keyboard km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft mysql oddnumber open opendocumentformat openwebfoundation pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string suggestions test threads unix urboc user variable whythiscodecausesegmentationfault win32api windows.h windowsapi






