473,385 Members | 1,919 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,385 software developers and data experts.

Need help figuring out what is wrong with my code?

I can get the program to compile and run, but my teacher is telling me this.

You are using the variables incorrectly.
You have an error in the subprogram that causes the subprogram output to
be incorrect. There should not be any local variables. Take them out and
use the variables in the parenthesis for the formal parameters. If you
declare the variables as local like you are doing, you are not using the
values that are being passed into the subprogram.


I've looked at my code over and over, and I don't see what she's talking about. Am I just over looking it?
Oct 24 '07 #1
4 1191
gpraghuram
1,275 Expert 1GB
I can get the program to compile and run, but my teacher is telling me this.

You are using the variables incorrectly.
You have an error in the subprogram that causes the subprogram output to
be incorrect. There should not be any local variables. Take them out and
use the variables in the parenthesis for the formal parameters. If you
declare the variables as local like you are doing, you are not using the
values that are being passed into the subprogram.


I've looked at my code over and over, and I don't see what she's talking about. Am I just over looking it?
Can u post the section of the code which u are looking into?

Raghuram
Oct 24 '07 #2
Can u post the section of the code which u are looking into?

Raghuram

My teacher was getting my lab confused with another students, so turns out nothing was wrong with my program.
Oct 25 '07 #3
Ganon11
3,652 Expert 2GB
Well, that's fortunate!
Oct 25 '07 #4
mattmao
121 100+
I can get the program to compile and run, but my teacher is telling me this.

You are using the variables incorrectly.
You have an error in the subprogram that causes the subprogram output to
be incorrect. There should not be any local variables. Take them out and
use the variables in the parenthesis for the formal parameters. If you
declare the variables as local like you are doing, you are not using the
values that are being passed into the subprogram.


I've looked at my code over and over, and I don't see what she's talking about. Am I just over looking it?
So far as I know, your teacher is suggesting you not use local variables but those in the function parameters.

Say, int myMethod(int *a)
{
//some code;
}

Your teacher may want to to change the "content" of the pointers(example, *a = 1;), not create new local variables and then return it back. At least my Professor named this after "call by reference":)
Oct 25 '07 #5

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

Similar topics

8
by: Nathan Pinno | last post by:
Hi all, I need help figuring out how to fix my code. I'm using Python 2.2.3, and it keeps telling me invalid syntax in the if name == "Nathan" line. Here is the code if you need it. #This...
12
by: gcary | last post by:
I am having trouble figuring out how to declare a pointer to an array of structures and initializing the pointer with a value. I've looked at older posts in this group, and tried a solution that...
9
by: james.calhoun | last post by:
OK... i think this is an easy question. I Have a number of Divs, and when you rollover the divs their border color changes. When You click on a div, I want the rollover state to stick. I...
18
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before....
2
by: kristopher.erickson | last post by:
Hereis some basic code that works fine: For Each itm In fld.Items I = I + 1 j = 1 Set rng = wks.Cells(I, j) If itm.Start <"" Then rng.Value = itm.Start j = j + 1
2
by: Anders B | last post by:
I want to make a program that reads the content of a LUA array save file.. More precicely a save file from a World of Warcraft plugin called CharacterProfiler, which dumps alot of information about...
4
by: =?Utf-8?B?UHVjY2E=?= | last post by:
The function that I'm trying to call through DLLImport has a parameter that has a C code's vector's Itrator to a structure. I Have marshalled the structure in C# but how do I do the C type...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
7
numberwhun
by: numberwhun | last post by:
Hello all! I am working on trying to figure out how to print out a hash of hashes. How the hash in the code is defined below is very similar to how the hash is defined in the script I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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
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
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
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...

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.