8 12 17 24 28 33 40...100 by while loop

So you not only expect us to write the program for you, but on top of that, we also have to figure out what the pattern/formula that generates "8 12 17 24 28 33 40...100" before we can even write the program? What's our incentive to do this for you?

No thanks.

// Jyt is a REPL for C++
// You can write code interactively

// Highlight some code and press alt-enter to execute it
// For example: 
auto x = "hello world"; 

// Now you can query the value in the terminal on the right
// e.g. "x"

// You can also update the value
// x = "hello again";

// The terminal on the right is meant for evaluating expressions.

// This window is on the otherhand for definitions. E.g.:
int foo(int x) {
  return x;
}

// And you can include libraries
#include<iostream>

int main(std::string x) {
  std::cout << x << " " << foo(42) << std::endl;
  return 0;
}

auto result = main(x);

// Press the "play" button to load this file and interact in the terminal.
// As C++ does not allow to redefine symbols, pressing "play" multiple times might cause errors.
// You can restart the whole enviroment by pressing the "reload" button.

Is this one yours too? It linked to your link under the Projects pulldown. main takes a std::string argument? That looked odd so I compiled it using g++ -std=c++11 just to doublecheck and it did not like that string argument. What is this site? Is that C++ code? Some offshoot?

@Assertnull. The fiddle must be one that doesn't share like others. Anyhow the OP's spec is too light. This has "8 12 17 24 28 33 40...100 by while loop". Nothing like programming to spec.

// Jyt is a REPL for C++

// And you can include libraries
#include<iostream>

int main() {
  while (false) // 8 12 17 24 28 33 40...100
  {
  }
  return 0;
}
auto result = main();
// Press the "play" button to load this file and interact in the terminal.
// As C++ does not allow to redefine symbols, pressing "play" multiple times might cause errors.
// You can restart the whole enviroment by pressing the "reload" button.

Your code above is what I got with your link, so link works fine. Then I did a quick peek around the site and quickly came across the code I posted. Try running it. It runs on the fiddle you linked but it us not valid C++ code. Try copying and pasting it into the fiddle. My question is is this a C++ fiddle and if so, why does the code I posted not give errors on the fiddle? Is there a bug in the fiddle?

#include <stdio.h>

int main(){
    int i,s=8;
    while(s<=100){
        printf("\t%d\n", s);
        switch(i){
            case 4: i+=1; break;
            case 5: i+=2; break;
            default: i=4;
        }
        s+=i;
    }
    return 0;
}

Sorry, but this is invalid code. i is not initialized before you use it in the switch statement. It will contain random values.

commented: Oh, sorry - it can initialize in line 4 by any value except 4 and 5 +5
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.