Total members 11791 |It is currently Sun Aug 18, 2019 10:54 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





While loop example in C++
cpp code
#include <stdio.h>
main()
{
int cnt = 0, /* Count of numbers read. */
tot = 0; /* Total of numbers read. */

/* Read until a read fails. */
int num;
while(scanf("%d", &num) == 1) {
tot = tot + num;
cnt = cnt + 1;
}

/* Print the average. */
if(cnt)
printf("Average is %g\n", (double)tot / (double)cnt);
else
printf("No numbers.\n");
}




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : C++ While loop
 do while loop and for loop C++ example help.     -  
 Do while loop     -  
 While loop     -  
 Using include() Within a Loop     -  
 Why will my loop does not work     -  
 Breaking a Loop     -  
 PIC Assembly For Loop Example     -  
 I NEED SOME HELP IN THE FOR LOOP PLZ .. IAM JUST A BEGINNER     -  
 Need help with code for a while loop program     -  
 for statement loop indefinitely     -  



Topic Tags

C++ Loops
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com