Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hellloooaaaa

Name: Anonymous 2011-10-10 15:12

#include<iostream>
using namespace std;



int main( )
 {
   
 int x, sum, counter, sonuc;
 sum = 0;
 counter = 0;
 

 
 cout<<"ortalamasini almak istediginiz 5 numara girin"<<endl;
 cout<<"enter a number"<<endl;
 cin>>x;
 sum = sum + x;
 counter = counter + 1;
 
 
 cout<<"enter another number"<<endl;
 cin>>x;
  sum = sum + x;
 counter = counter + 1;

 cout<<"enter another number"<<endl;
 cin>>x;
  sum = sum + x;
 counter = counter + 1;
  cout<<"enter another number"<<endl;
 cin>>x;
  sum = sum + x;
 counter = counter + 1;
  cout<<"enter another number"<<endl;
 cin>>x;
  sum = sum + x;
 
 counter = counter + 1;
 sonuc = sum/counter;
 
 
 cout<<"sonuc = ";
 cout<<sonuc<<endl;
 
 system("PAUSE");
 
   return 0;
}





teach me how to loop this.yes,i'm a complete retard.

Name: Anonymous 2011-10-10 17:15

You need to use something called a label. Put this where you want your loop to start:

loop:

and then when you want to loop, you write goto loop;

For example:

int i = 0;

loop:
    puts("This gets executed 5 times.");

if (i++ < 5)
    goto loop;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List