Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer audio black screen blue screen boot bsod computer connection crash css dell driver drivers email error ethernet excel explorer firefox firefox 3 hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook 2007 outlook express partition problem router security slow software sound trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Programming in C Help!!


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Rhino24's Avatar
Member with 41 posts.
 
Join Date: Feb 2008
Experience: Beginner
14-Mar-2008, 03:20 AM #1
Programming in C Help!!
How to you write a algorithm (blocks of code) for these:?
a.) Obtain two numbers from the keyboard, and determine and display which (if either) is the larger of the two numbers.

b.)Obtain a series of positive numbers from the keyboard, and determine and display the sum of the numbers. Assume that the user types the sentinel value -1 to indicate “end of data entry”.
burnthepc's Avatar
Computer Specs
Senior Member with 186 posts.
 
Join Date: Aug 2007
Experience: Intermediate
14-Mar-2008, 06:09 AM #2
This is the simplest:

A)

int main()
{
int num1, num2;
cin >> num1 >> num2;

if(num1 > num2)
cout << num1;
else cout << num2;
// note: if they are the same value num2 is output

return 0;
}

B)

int main()
{
int x;
int sum = 0;
while(cin >> x)
{
if(x == -1) break;
sum += x;
}

cout << sum;
return 0;

}

You can mess with the formatting to your taste.

Rhino, I see you're posting a lot of questions for your course up here. I'd advise checking out these pages:

http://www.cplusplus.com/doc/tutorial/

Once you've done the tutorial then you should be able to do the questions easily...note that the above is for C++ not C, but a lot of the basic rules still hold.

Last edited by burnthepc : 14-Mar-2008 06:18 AM.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:09 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.