GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Mar-2004, 22:01
soulfly soulfly is offline
New Member
 
Join Date: Mar 2004
Posts: 8
soulfly is on a distinguished road

Please Help, problems writing newbie C program ReREVISED


CPP / C++ / C Code:
/*  Group Project pg 299, # 58
    written by:  
	3-3-04 

This program reads a list of integers from the keyboard and creates the following information:
find and print the sum and the average of the integers, find and print the largest and smallest
integer, print a boolean true or false if some of them are less than 20, print a boolean 
true or false if all of them are betrween 10 and 90.*/




#include <stdio.h>

/* Prototype Declarations*/



int main (void)

{

/*Local Definitions*/

int num = 0;
int secondnum = 0;
int sum = 0;
float avg = 0;
float largest = 0;
float smallest = 0;
float boolone = 0;
float booltwo = 0;
float boolean = 0;
int totalintegers = 0;

/*Statememts*/

/*Main*/

printf(" Please enter numbers: <return> : Enter 99999 to stop\n");


do

{
scanf("%f",&num);
totalintegers ++;
secondnum += num;
sum = num + num;
avg = sum / totalintegers;

if (num > num)

		largest = num;

	else

		smallest = num;

if (num < 20 )

		boolone = 1; 

	else

		boolone = 0;

	if (num > 10 && num < 90)

		booltwo = 1;

	else

		booltwo = 0;



}

while (num!=99999);


printf(" The number of integers is:              %d\n",totalintegers);
printf(" The sum of the integers is:            %d\n",sum);
printf(" The average of the intergers is:        %f\n",avg);
printf(" The smallest integer is:                %f\n",smallest);
printf(" The largest integer is:                 %f\n",largest);

if (boolone !=0)
     
     printf(" True, some of the integers are less than twenty\n");

else

     printf(" False, none of the integers are less than twenty\n");

if (booltwo!=0)
  
    printf(" True, all of the integers are between 10 and 90\n");

else

    printf(" False, none of the integers are between 10 and 90\n");

return 0;

}
/* end main*/
Last edited by dsmith : 02-Mar-2004 at 22:23. Reason: Added C syntax highlighting
 
 

Recent GIDBlogDeveloping GUIs with wxPython (Part 4) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please Help, problems writing newbie c program soulfly C Programming Language 14 04-Mar-2004 15:16
Please Help, problems writing c program REVISED soulfly C Programming Language 6 03-Mar-2004 13:57

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:49.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.