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

Summation questions

NewYorker
PLEASE PLEASE PLEASE HELP ME ... I AM SO CONFUSED

Q1:
Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0.

__________________________________________________ ______________


Q2:
Assume the int variables i , lo , hi , and result have been declared and that lo and hi have been initialized.
Write a for loop that adds the integers between lo and hi (inclusive), and stores the result in result .
Your code should not change the values of lo and hi . Also, do not declare any additional variables -- use only i , lo , hi , and result .

__________________________________________________ ______________

Q3:
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 whole numbers, and store this value in total . Thus your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total . Use no variables other than k and total .

__________________________________________________ ______________

Q4:
Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .
__________________________________________________ ______________

Q5:
Assume the int variables i and result , have been declared but not initialized. Write a for loop header -- i.e. something of the form
for (* . * . * . * )
for the following loop body:
result = result * i;
When the loop terminates, result should hold the product of the odd numbers between 10 and 20.
NOTE: just write the for loop header; do not write the loop body itself.
Oct 16 '06 #1
3 8178
Don't mean to be a spoiler, but which parts specifically don't you understand? It might help if you put in what you can already work out and relate your questions to that.

When I was at school, they never actually gave us the questions before hand, or perhaps these are just examples.

But please, throw in some code and we can explain what you don't understand or are missing.
Oct 16 '06 #2
these Are Given As Exam Preparation ... Can Anybody Help ..?
Oct 16 '06 #3
Banfa
9,065 Expert Mod 8TB
You should attempt these yourself first and post you code with the problems you are having.

If you are unable to do this for any (or all) question because of you confusion then you should post saying what it is about each question that is confusing you.

Tackle them 1 question at a time, do 1 first, while you are doing 1 do not consider the other questions.
Oct 16 '06 #4

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

Similar topics

0
by: softwareengineer2006 | last post by:
All Interview Questions And Answers 10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP) I have listed over 10000 interview questions asked in interview/placement test papers for...
0
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
2
by: freepdfforjobs | last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions http://www.questpond.com/SampleInterviewQuestionBook.zip Download the JAVA , .NET and SQL Server interview sheet and rate...
4
by: Drew | last post by:
I posted this to the asp.db group, but it doesn't look like there is much activity on there, also I noticed that there are a bunch of posts on here pertaining to database and asp. Sorry for...
1
by: crazydrummer | last post by:
hi everyone, fairly new to access and VBA, but have fundamental knowledge. as part of a college project i am building a database that records "downtime" for machines in a company. the...
7
abouddan
by: abouddan | last post by:
Hi all I am using Access2000 and I am creating a report based on a query. Query1=" select Id,name,Amount from Eployees" This query returns many records, so in the report this result must...
6
by: logieen | last post by:
Hi , Every one I have a problem to solve this summation in c++ ; 1/3 + 3/5 +5/7 ....... this the program I wrote #include <stdio.h> #include <iostream.h> #include <conio.h> #include...
25
by: Darsin | last post by:
Hi all I need to perform a summation on a column of a table based on a criteria given in another column in the same table. The catch is i need to perform different sums according to the number of...
32
by: =?ISO-8859-1?Q?Szabolcs_Horv=E1t?= | last post by:
I did the following calculation: Generated a list of a million random numbers between 0 and 1, constructed a new list by subtracting the mean value from each number, and then calculated the mean...
2
by: galaxianape | last post by:
Please help me with summation in C lang. I m trying to divide the summation of alpha * delta with summation of alpha this is half the program that i have written...but it gives error. pls help.....
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: 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
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...
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...

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.