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

a code problem

this is a practice question that has me baffled
I am providing my answer, but to tell you the truth I do not see enought info to
answer the question. the question is : fill in the blank linebelow

sum=0;
for(k=0; k<50; k++)
for (j=0; j<7; j++)
sum= sum +________________
my answer is sum =sum+ K ++ J ++

but I have been told it was wrong, what is the solution?
Mar 25 '10 #1
9 1425
donbock
2,426 Expert 2GB
You need a semicolon at the end of the line. I can't say much more than that without knowing what this code snippet is trying to accomplish.

The double-plus (++) are almost certainly wrong; although I suppose it might be possible to invent a problem statement that required them.

How does this relate to your almost identical other post? You shouldn't double-post.
Mar 25 '10 #2
jkmyoung
2,057 Expert 2GB
You're already incrementing k and j in the for loop, why do it again?
Plus variables are case sensitive, so you need to use j and k, not J and K.
Mar 25 '10 #3
RedSon
5,000 Expert 4TB
What is sum supposed to be the sum of? Is it supposed to be the sum of itself and J and K?

And why are you double posting?
Mar 25 '10 #4
My guess would be that sum is meant to be a counter for the number of times gone though the loop so could you try use 1?
Mar 26 '10 #5
sum+ K ++ J ++:
J++ is j=j+1;
k++ is k=k+1
So sum+k++J++ is sum+(k+1)(j+1) then what is the answer
Mar 27 '10 #6
whodgson
542 512MB
I believe jkmyoung has solved the problem.
Mar 29 '10 #7
RedSon
5,000 Expert 4TB
why do you think that?
Mar 29 '10 #8
compiler can not identify k++J++
Mar 29 '10 #9
whodgson
542 512MB
@RedSon
By saying that, I was attempting to encourage someone into providing the correct answer with its logic
Mar 29 '10 #10

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

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
8
by: Paul Cochrane | last post by:
Hi all, I've got an application that I'm writing that autogenerates python code which I then execute with exec(). I know that this is not the best way to run things, and I'm not 100% sure as to...
8
by: Steve Jorgensen | last post by:
Hi folks, I'm posting this message because it's an issue I come up against relatively often, but I can't find any writings on the subject, and I haven't been able to figure out even what key...
2
by: Praveen K | last post by:
I have a problem in communicating between the C# and the Excel Interop objects. The problem is something as described below. I use Microsoft Office-XP PIA dll’s as these dll’s were been...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
8
by: Andy B | last post by:
Before I do a no no on a newsgroup, I need to ask a question: What is the max number of lines of code you can/should post here before it gets too long?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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,...

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.