C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 12th, 2006, 06:49 PM
jdm bb6 jdm bb6 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 2 jdm bb6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 40 sec
Reputation Power: 0
C project

i have taken C++ in the past but to me down grading is different. i do not really understand the pow and square root functions itself.. can someone please help me to understand and how to use them like examples:

Project 3 - 15 points

This project deals with range-based loops where we know the exact number of
times a loop will iterate (perform the associated block of code).


Given:

int x, lower, upper;
double square, squareroot;


Have the user enter a lower bound and an upper bound for a range of integers.

You will then construct a for loop to process the range of values from the
lower bound to the upper bound, inclusive, incrementing by one each time.

Each time through the loop, using the pow and sqrt functions, calculate the
square and square root of each value and store the result in the appropriate
variable. Display your results.


Your output should resemble:

Enter a lower bound: 3
Enter an upper bound: 9
For the value 3 the square is 9.00 and the square root is 1.73
For the value 4 the square is 16.00 and the square root is 2.00
For the value 5 the square is 25.00 and the square root is 2.24
For the value 6 the square is 36.00 and the square root is 2.45
For the value 7 the square is 49.00 and the square root is 2.65
For the value 8 the square is 64.00 and the square root is 2.83
For the value 9 the square is 81.00 and the square root is 3.00

NOTE: The user entered 3 and 9 in the above test!



This project should be called p3.c and submitted using:

$ submit jojo p3.c

__________________________________________________ __

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main ()
{
int x, lower, upper, i, num; /* assigning integer values*/
double square, squareroot; /* assigning double float values*/

printf("Enter two values, a lower and an upper bound please: ");
scanf("%d", lower);
scanf("%d", upper);

for(i=lower;i<upper;i++){
printf("x = x*x");
printf("x = x*x*x");
}

printf("%d,%d,%d");

}

Thanks for your help
-D

Reply With Quote
  #2  
Old June 12th, 2006, 07:02 PM
jdm bb6 jdm bb6 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 2 jdm bb6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 40 sec
Reputation Power: 0
got that complete, sorry about that fluke...

project 4:

Project 4 - 15 points

This project deals with sentinel-based loops where we do not know the exact
number of times a loop will iterate (perform the associated block of code).

Use the variables given below to solve the problem. You should need no other
variables to complete this project.


Given:

int num, sum, valid, invalid;
float avg;



Using your knowledge of C and using num as your loop control variable, write
a while loop to read positive integers from the user until the user enters the
integer value -1. This is the sentinel value indicating that the user has
finished entering data.

As you are reading in the values you should be keeping track of how many
positive values have been read so far (valid) simultaneously keeping a running
total (sum). The user must use -1 to terminate the program, but may enter a
value less than -1. You should not include these values in the running total
or in the number of positive values read from the user. Instead you should
increment the count of invalid numbers entered by the user.

Zero should be considered a positive value for the extent of this project.

You will report to the user the number of positive values they entered, the
number of invalid values, the sum and average of the positive values. The
average should should be displayed as a floating point value.




This project should be called p4.c and submitted using:

$ submit jojo p4.c

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > C project


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT