| | |
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: 7
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 |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling segmentationfault send shape socketprograming socketprogramming stack standard strchr string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h






