473,412 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Some C++ Doubts

I am new to C++, was writing a simple program when this Statement error pops up.

The code of my program is:-

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2.  int main ()
  3.  int P, R, T, I ;
  4.  cout<<"Enter The Principle(In Rupees):";
  5.  cin>>P;
  6.  cout<<" The Rate is:";
  7.  cin>>R;
  8.  cout<<"The time (In Years)is :";
  9.  cin>>T;
  10.  I=(P*R*T)/100
  11.  cout<<"The Simpe Interst Is:"<<I;
  12.  return 0;
  13. }
P.S:-
1. It shows statement missing after the last bracket("}") sometimes.
2. Whenever i run some programme, It automatically closes as soon as I enter the values of , say, a and b.
3. After I rerun a program, the values of the previous time i ran a program also shows up and i dont want it.

Please Explain all of it

Thanks.
Regards, Purnaabh
Nov 17 '15 #1
5 2008
I got the mistake in my programme, ";" was missing after the I=(P*R*T)/100.

I guess that was the problem in the statement missing error after } too.

I would still like to have an explanation of what a "Statement Error" is and the other two doubts.
Nov 17 '15 #2
weaknessforcats
9,208 Expert Mod 8TB
What you call a bracket } is called a brace. { is an opening brace and } is a closing brace.

A bracket is either an opening bracket [ or a closing bracket ].

When you run your program your computer is so fast the program executes in the blink of an eye. You need to stop it at the end so you can see your results. Just add a cin>> as your last statement and the program will have to stop so you can enter a value. Now you can see your results.

As to seeing the previous program run's values, can you tell me more about that. BTW you should initialize all your variables when you create them. Does this problem go away if you initialize your variables to zero?
Nov 17 '15 #3
I did not get what you wanted to say by initializing all your variables to 0, but i guess you mean

"int P=0,R=0,T=0,I=0"



I did it, here's the screenshot. I guess you understand now what i meant by previous program values.
I tried cin>> thing, it worked fine.
I initialized my variables to 0, it seemed to have no effect on the program.(atleast it looked like that it did not, lol)



P.S:-

1.How can i copy, say a code from this webpage to the c++ programming screen?

2. A friend of mine suggested introducing somethings, I don't quite remember, i guess it was clrscreen & getch.
Please explain to me what those two things are and the first one too.


Thanks
Nov 18 '15 #4
weaknessforcats
9,208 Expert Mod 8TB
Back in 1968 when C was invented, the output always went to the computer console typewriter. This typewriter was feeding a continuous sheet of folded paper so your different tests would be scrolled on the paper. It appears your C++ implementation is doing the same thing. The data just rolls up the screen.

You could just use cout and display enough \n to scroll any data that might be on the screen off the top of the screen before your program starts displaying its own data.

There are various ways to dink with the console screen and they are all non-standard, non-portable, and a bad practice. That said this might work to clear the screen:

Expand|Select|Wrap|Line Numbers
  1.  system("cls");
This code doesn't work on all machines.

Remember, the condole screen is supposed to be continuous scrolling up. It is not a UI for a window.
Nov 18 '15 #5
1.How can i copy, say a code from this webpage to the c++ programming screen?

2. A friend of mine suggested introducing somethings, I don't quite remember, i guess it was clrscreen & getch.
Please explain to me what those two things are and the first one too.


Please explain these two also, thanks.
Nov 22 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Piotre Ugrumov | last post by:
I have some problems and some doubts. I have implemented a class hierachy. The base class Velivolo, from Velivolo derive Militare and Civile, from militare derive Aereo and Elicottero, from Civile...
6
by: Chua Wen Ching | last post by:
Hi there, I have some questions to ask... just say i have this xml file: Scenario :- Script.xml ======== <software> <settings>
1
by: Jitesh | last post by:
I have created a webservice, If anybody use that webservice(by instansiating the webservice object), then I want to know the IP address and Url of the site which is using my webservice. How can I...
0
by: muttu2244 | last post by:
hi everybody, i want to check the position of a volume in a particular drive. say for example in a disk i have 3 different drives: C:\ , D:\ and E:\. Now if i want to check what position is...
8
by: lovecreatesbeauty | last post by:
Hello experts, I have seen following the code snippet given by Marc Boyer (with slight changes by me for a better format), and have doubts on it. I am so grateful if you can give me your kindly...
2
by: alberto.ribao | last post by:
Hello, I'm making some proofs of concept about localization with .NET Framework 2.0 My trouble is I'm trying to display the next string with a call to MessageBox.Show method: ...
7
by: ramasubramanian.rahul | last post by:
hi i was trying to see how the compiler hides the static golbals from the linker and allows golbal varibale to be visable to the linker.i managed to figure out how it did that ( the .lcomm and...
1
by: ramasubramanian.rahul | last post by:
hi people.. dont know if this the right forum for this doubt ... so sorry if i am mis-posting... i was looking at the way glib 2.10.3 does export optimization using a list of "to be exposed"...
11
by: destination | last post by:
struct X { int x,y; char c; }; main() { struct X x,*px; px=&x;
2
by: sasimca007 | last post by:
If we are using Apache1.3.31 version then in man apache will come and we can use default functions and variables like document_root and send_http_header() etc... But in Apache2 version what is the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.