i was told tht from this:

int main () 
{
    int i,j,vsota;
    for (i=1; j=10; i<=j; i++)
{
     vsota=vsota+i+j;
     j--;
}
system ("pause"); 
return 0; 
}

i must make it work with while ;
but the oruginal doesnt work allso
what should i doo??;
please any help;?

#include <iostream> 
using namespace std;

int main () 
{ 
int i = 1,vsota,j; 


while (j=10;i<=j) 
{ 
      vsota = vsota + i + j;
      j--; 
      i++; 
}
system("pause); 
return 0; 

i think it would be better if u initialize j outside while, because first

while (j=10;i<=j)

it will initiliaze j = 10 then test if i <= j. after the first loop has been done,
j will have j-- means j = 9, but then when it meets

while (j=10;i<=j)

j will become 10 again because of the "j = 10"

also i think it would be better too if u initilialize the variable vsota.

edited : u shud put the initiliatization outside the loop

while(j=10; i<=j)

change to =

     j = 10;
     while(i<=j)
     {
        //code
     }

and so does the for loop

for (i=1; j=10; i<=j; i++)

change to =

 j = 10;
    for(i = 1; i<= j; i++)
    {

    }

please correct me if im wrong

in the for loop to double initialize use a comman [,] not [;]
the rest I agree with Sedy Hippo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.