...

/

Exercises on Control Flow

Exercises on Control Flow

Enhance your programming by practicing loops and conditionals.

The solutions for the exercises are included in the solution tabs. For best learning outcomes, don’t look at these unless you’ve attempted the problems yourself.

Question 1: FizzBuzz

Write a program that prints the numbers from 1 to 100 with the following exceptions:

  • For multiples of 3, print “Fizz” instead of the number.
  • For the multiples of 5, print “Buzz” instead of the number.
  • For numbers that are multiples of both 3 and 5, print “FizzBuzz” instead.

Try solving here:

Press + to interact
#include <stdio.h>
int main(void)
{
// Your code goes here
return 0;
}

Question 2: Newton’s method

Write a program to estimate the square root of 612 using Newton’s method, using 5 iterations.

...
Press + to interact
#include <stdio.h>
int main(void) {
// Your code goes here
return 0;
}
...