#include <iostream>
int main()
{
int sum = 0;
for(int i = 2; i < 100; i += 3)
{
sum += i;
}
std::cout << "Sum is " << sum;
return 0;
}
#include <iostream>
int main()
{
int i = 2;
int sum = 0;
while(i < 100)
{
sum += i;
i += 3;
}
std::cout << "Sum is " << sum;
return 0;
}
#include <iostream>
int main()
{
int i = 2;
int sum = 0;
do
{
sum += i;
i += 3;
} while(i < 100);
std::cout << "Sum is " << sum;
return 0;
}
Comments
Leave a comment