A conversion table of feet to meters : for loop « Operators statements « C++ Tutorial

Home
C++ Tutorial
1.Language Basics
2.Data Types
3.Operators statements
4.Array
5.Development
6.Exceptions
7.Function
8.Structure
9.Class
10.Operator Overloading
11.Pointer
12.File Stream
13.template
14.STL Introduction
15.string
16.vector
17.list
18.bitset
19.set multiset
20.valarray
21.queue stack
22.deque
23.map multimap
24.STL Algorithms Modifying sequence operations
25.STL Algorithms Non modifying sequence operations
26.STL Algorithms Binary search
27.STL Algorithms Sorting
28.STL Algorithms Merge
29.STL Algorithms Min Max
30.STL Algorithms Iterator
31.STL Algorithms Heap
32.STL Algorithms Helper
C / ANSI-C
C Tutorial
C++
Visual C++ .NET
C++ Tutorial » Operators statements » for loop 
3.15.2.A conversion table of feet to meters
#include <iostream>  
using namespace std;  
  
int main() {   
  double f; // holds the length in feet  
  double m; // holds the conversion to meters  
  int counter; 
 
  counter = 0
 
  for(f = 1.0; f <= 100.0; f++) { 
    m = f / 3.28// convert to meters 
    cout << f << " feet is " << m << " meters.\n";  
     
    counter++;  
 
    // every 10th line, print a blank line 
    if(counter == 10) { 
      cout << "\n"// output a blank line 
      counter = 0// reset the line counter 
    
  
 
  return 0
}
1 feet is 0.304878 meters.
2 feet is 0.609756 meters.
3 feet is 0.914634 meters.
4 feet is 1.21951 meters.
5 feet is 1.52439 meters.
6 feet is 1.82927 meters.
7 feet is 2.13415 meters.
8 feet is 2.43902 meters.
9 feet is 2.7439 meters.
10 feet is 3.04878 meters.

11 feet is 3.35366 meters.
12 feet is 3.65854 meters.
13 feet is 3.96341 meters.
14 feet is 4.26829 meters.
15 feet is 4.57317 meters.
16 feet is 4.87805 meters.
17 feet is 5.18293 meters.
18 feet is 5.4878 meters.
19 feet is 5.79268 meters.
20 feet is 6.09756 meters.

21 feet is 6.40244 meters.
22 feet is 6.70732 meters.
23 feet is 7.0122 meters.
24 feet is 7.31707 meters.
25 feet is 7.62195 meters.
26 feet is 7.92683 meters.
27 feet is 8.23171 meters.
28 feet is 8.53659 meters.
29 feet is 8.84146 meters.
30 feet is 9.14634 meters.

31 feet is 9.45122 meters.
32 feet is 9.7561 meters.
33 feet is 10.061 meters.
34 feet is 10.3659 meters.
35 feet is 10.6707 meters.
36 feet is 10.9756 meters.
37 feet is 11.2805 meters.
38 feet is 11.5854 meters.
39 feet is 11.8902 meters.
40 feet is 12.1951 meters.

41 feet is 12.5 meters.
42 feet is 12.8049 meters.
43 feet is 13.1098 meters.
44 feet is 13.4146 meters.
45 feet is 13.7195 meters.
46 feet is 14.0244 meters.
47 feet is 14.3293 meters.
48 feet is 14.6341 meters.
49 feet is 14.939 meters.
50 feet is 15.2439 meters.

51 feet is 15.5488 meters.
52 feet is 15.8537 meters.
53 feet is 16.1585 meters.
54 feet is 16.4634 meters.
55 feet is 16.7683 meters.
56 feet is 17.0732 meters.
57 feet is 17.378 meters.
58 feet is 17.6829 meters.
59 feet is 17.9878 meters.
60 feet is 18.2927 meters.

61 feet is 18.5976 meters.
62 feet is 18.9024 meters.
63 feet is 19.2073 meters.
64 feet is 19.5122 meters.
65 feet is 19.8171 meters.
66 feet is 20.122 meters.
67 feet is 20.4268 meters.
68 feet is 20.7317 meters.
69 feet is 21.0366 meters.
70 feet is 21.3415 meters.

71 feet is 21.6463 meters.
72 feet is 21.9512 meters.
73 feet is 22.2561 meters.
74 feet is 22.561 meters.
75 feet is 22.8659 meters.
76 feet is 23.1707 meters.
77 feet is 23.4756 meters.
78 feet is 23.7805 meters.
79 feet is 24.0854 meters.
80 feet is 24.3902 meters.

81 feet is 24.6951 meters.
82 feet is 25 meters.
83 feet is 25.3049 meters.
84 feet is 25.6098 meters.
85 feet is 25.9146 meters.
86 feet is 26.2195 meters.
87 feet is 26.5244 meters.
88 feet is 26.8293 meters.
89 feet is 27.1341 meters.
90 feet is 27.439 meters.

91 feet is 27.7439 meters.
92 feet is 28.0488 meters.
93 feet is 28.3537 meters.
94 feet is 28.6585 meters.
95 feet is 28.9634 meters.
96 feet is 29.2683 meters.
97 feet is 29.5732 meters.
98 feet is 29.878 meters.
99 feet is 30.1829 meters.
100 feet is 30.4878 meters.
3.15.for loop
3.15.1.Simplest for loop statement
3.15.2.A conversion table of feet to meters
3.15.3.Use multiple statements in for loops
3.15.4.Display the alphabet: use char to control for loop
3.15.5.A negatively running for loop
3.15.6.Loop until a random number that is greater than 20,000.
3.15.7.A for loop with no increment
3.15.8.The body of a for loop can be empty
3.15.9.Declare loop control variable inside the for
3.15.10.Use nested for loops to find factors of numbers between 2 and 100
3.15.11.For loops with null statements
3.15.12.empty for loop statement
3.15.13.Compound interest calculations with for
3.15.14.Floating point control in a for loop
3.15.15.Generating multiplication tables
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.