Link to home
Start Free TrialLog in
Avatar of f19l
f19l

asked on

Writing a very basic C++ block of code.

Hello,

I need  to write a program which reads a value in the
form ddd.dd, increases it by 10% and then prints it
on the screen. I will also need another program that accepts input in the form of
ddd:dd.

Thanks.
Avatar of kaufmed
kaufmed
Flag of United States of America image

I need  to write a program which reads a value in the
form ddd.dd, increases it by 10% and then prints it
on the screen. I will also need another program that accepts input in the form of
ddd:dd.
Fantastic!!!  What have you done so far??
Avatar of f19l
f19l

ASKER

Here is what I have done:

#include <stdio.h>
int main()
{
int a=-1;
int b=-1;
double result=(a+b*0.01)*1.10;
scanf("%3d",c);
printf("The result is: %f \n", result);
getchar();
getchar();
}
It is C not C
If it is not a homework assignment, I can give you the program.  Is it?
Avatar of f19l

ASKER

I am self-studying C so it is something that I have assigned myself as it relates to something I need to do for work.
Avatar of f19l

ASKER

Would this work in C?
No, the libraries are totally different.  This is C++ because you asked in C++ zone.

Concepts and ideas are exactly the same but the libraries are different.  Why don't you study the links I sent you and ask any questions you may have.
What compiler are you using? Is it Windows or Linux?
Avatar of f19l

ASKER

Windows.
Is it VC++?  Try running the program on your compiler, may be that would work.
Avatar of f19l

ASKER

I am using the compiler that I downloaded from the MS website; Visual 2010 Studio Express.
That should run it without a problem.
You have to make a data file yourself as I named it "t", name is something and change the name in the program.
File reads like
123.45
Avatar of f19l

ASKER

Hello,

I am trying to do this in C.

f19l.
Evilrix,

You may be right but in all the other programming zones like Perl, Python, Bash, Ksh, etc., everyone gives away the complete code and no one ever objected, including mods.  Weird.
Evilrix:  Kindly quote the policy that says that you cannot give a solution to a problem that is not a homework, as in this case.

This policy relates only to homeworks
https://www.experts-exchange.com/help.jsp?hi=21

I need to know about a policy of not giving a solution to a non homework problem.  Because, if that is the case, I have hundreds of examples of users who have been on EE since 1998 and they always give a complete solutions.  I am to be sure for future.
ASKER CERTIFIED SOLUTION
Avatar of farzanj
farzanj
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you have
float real;

then you need to read like

    fscanf(ifp,"%f", &real);
    printf("This is the increased num %.2f\n",real * 1.1 );