We help IT Professionals succeed at work.

Writing a very basic C++ block of code.

f19l
f19l asked
on
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.
Comment
Watch Question

SILVER EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
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??
BRONZE EXPERT

Commented:

Author

Commented:
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();
}
BRONZE EXPERT

Commented:
It is C not C
BRONZE EXPERT

Commented:
BRONZE EXPERT

Commented:
If it is not a homework assignment, I can give you the program.  Is it?

Author

Commented:
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.

Author

Commented:
Would this work in C?
BRONZE EXPERT

Commented:
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.
BRONZE EXPERT

Commented:
What compiler are you using? Is it Windows or Linux?

Author

Commented:
Windows.
BRONZE EXPERT

Commented:
Is it VC++?  Try running the program on your compiler, may be that would work.

Author

Commented:
I am using the compiler that I downloaded from the MS website; Visual 2010 Studio Express.
BRONZE EXPERT

Commented:
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

Author

Commented:
Hello,

I am trying to do this in C.

f19l.
BRONZE EXPERT

Commented:
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.
BRONZE EXPERT

Commented:
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
http://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.
BRONZE EXPERT
Commented:
Back to the subject:

Follow this link.  It is very good.  It shows a number of pieces that you need
http://www.cs.bu.edu/teaching/c/file-io/intro/
BRONZE EXPERT

Commented:
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 );

Explore More ContentExplore courses, solutions, and other research materials related to this topic.