Ni plak kitorang belajar pasal nak tukarkan for loop statement kepada while loop statement.
kat bawah ni contoh nak tukarkan statement ni....
#includde<iostream.h>
main()
{
//declare variable
int x,y;
//get input
cout<<"enter an interger=";
cin>>x,4
//loop for...
for(y=1; y<x; y++)
{
(cout<<" "<<x;
}
}
*yang kat atas ni ialah for loop.kalau ade soalan nak kite tukarkan kepada while loop, kite buat jer macam kat bawah ni...
#include<iostream.h>
main()
{
int x,y;
cout<<"enter an interger=";
cin>>x;
//while
y=1;
while(y<x)
{
cout<<"enter an interger= ";
y++;
}
}
Saturday, March 26, 2011
For loop statement to while loop statement
Posted by mohammad at 9:04 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment