473,396 Members | 2,010 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,396 software developers and data experts.

Whats wrong

I am a new young programer and i have recently started learning c++ I made a simpile script but something is wrong.


Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6.     int x;
  7.     unsigned short int y;
  8.      unsigned long int z;
  9.  
  10.      signed short int a;
  11.      signed long int b;
  12.  
  13.      y = 10;
  14.      z = 100000;
  15.      a = -12;
  16.      b = -5666666;
  17.  
  18.      cout << y << endl;
  19.      cout << z << endl;
  20.      cout << a << endl;
  21.      cout << b << endl;
  22.  
  23.  
  24.  
  25.      cin.get();
  26.      return 0;
  27.  
  28. }
Jul 16 '13 #1
9 1482
Banfa
9,065 Expert Mod 8TB
You haven't said what is wrong. Looking at the code it declares 5 variables, assigns values to 4 of them and prints out those 4 variables.

The only error appears to be that you never use variable 'x' and that is a fairly minor one.

BTW it is not a script, a script is a file that is executed by a runtime interpreter like php or qbasic. This is a code file that you will compile into an executable.
Jul 16 '13 #2
Xillez
93 64KB
Just remove the "int x;" and the code should work....

At:
Expand|Select|Wrap|Line Numbers
  1.      y = 10;
  2.      z = 100000;
  3.      a = -12;
  4.      b = -5666666;
  5.  
Add the variable type to each y, z, a and b...

Int z = 10 and so on...

But it should work without the int's...
Jul 16 '13 #3
donbock
2,426 Expert 2GB
"Something is wrong".
We can't really help you until you describe what is wrong. What are the symptoms?
Jul 16 '13 #4
in your program u put the iostream , but compiler needs iostream.h
Jul 20 '13 #5
muthuct8, iostream is one of those include headers that does not use .h when you include it (at least it doesn't requires it). The same is true for vector and string includes.
Jul 20 '13 #6
Xillez
93 64KB
Try to remove the int x;!:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6.      //removed the "int x;" because you don't use it here in this case... 
  7.      unsigned short int y;
  8.      unsigned long int z;
  9.  
  10.      signed short int a;
  11.      signed long int b;
  12.  
  13.      y = 10;
  14.      z = 100000;
  15.      a = -12;
  16.      b = -5666666;
  17.  
  18.      cout << y << endl;
  19.      cout << z << endl;
  20.      cout << a << endl;
  21.      cout << b << endl;
  22.  
Aug 1 '13 #7
donbock
2,426 Expert 2GB
@Xillez: a spurious variable definition (such as you suggest "int x" to be in the code sample) does not cause any runtime problems. It might cause a compiler warning. We still don't know what @dshfbhsdgz1 saw. Maybe it was a warning; maybe it wasn't.
Aug 2 '13 #8
Xillez
93 64KB
true, then I'm sorry, but dshfbhsdgz1 add the hole file in with all you're source code.. and copy and paste the error/warning from the program you use... btw, what program do you use?
Aug 2 '13 #9
There's nothing wrong with this code... Other than the un-used variable x. signed is implied even if you don't specify that btw.
Aug 12 '13 #10

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

Similar topics

3
by: Chris Geerdink | last post by:
combo with PHP. what is wrong with the Javascript? else { include("mysql.php"); $query1 = mysql_query("INSERT INTO gbook (naam, email, text) VALUES ('".$_POST."', '".$_POST."',...
4
by: asdf | last post by:
Hello! Can someone tell me whats wrong with this piece of code: Option Compare Database Option Explicit Sub retrieve() Dim rst As ADODB.Recordset Dim i As Integer
5
by: Alexandre Martins | last post by:
Provider=Microsoft.Jet.OLEDB.4.0;UserId=Admin;Password=teste;Data Source=C:\Inetpub\wwwroot\inktoner\dados\db_inktoner.mdb;Persist Security Info=True I can't connect in my database ! whats...
1
by: aa | last post by:
When I am reading from local disk (d:), everithing is OK, but then I am reading from map disk I am geting the this error. Whats wrong. Thanks Server Error in '/Extra' Application....
3
by: mahsa | last post by:
Hi do you know whats wrong with this code? <asp:HyperLink id="HLink_Help" runat="server" NavigateUrl='<%# "javascript:window.open('comments.aspx?id=1,width=500,height=600, scrollBars=yes');"...
4
by: blah | last post by:
Hello everyone, Ive been trying to get my application to "click" on a button in another application using SendMessage, Ive gotten this far but Im not sure whats wrong with this code, here is the...
1
by: '~=_Slawek_=~' | last post by:
$DOW = (jddayofweek(unixtojd(mktime(1, 1, 1, $month, $day, $year)))+6)%7; $DOW= (jddayofweek(juliantojd($month, $day, $year))+6)%7; The results are supposed to be the same, but they are not....
0
by: Jim Andersen | last post by:
I am using Microsoft.ApplicationBlocks.Data (v 2.0.0.0). I have this parameter array I pass to a stored procedure. The last one is an output parameter. So I did this: Line 1: arParms(8) = New...
7
by: Mike Barnard | last post by:
It's a simple test... VERY SIMPLE. But... In an external stlyesheet some attributes don't show. With the same styles cut and pasted to the test internally it works as expected. Anyone tell...
5
by: islayer | last post by:
can someone tell me what is wrong with the bold code? i am just learning perl. the program should create a perl file with a random name (5 letters, followed by a number), but the name is always just...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.