How to Fix Basic Beads Count in C

The difficulty

2 red beads are put in between every 2 blue beads. There are N blue beads. After taking a look at the plan listed below exercise the variety of red beads.

@ @@ @ @@ @ @@ @ @@ @ @@ @

Implement count_red_beads( n) ( countRedBeads( n)) so that it returns the variety of red beads.
If there are less than 2 blue beads return 0.

The option in C

Choice 1:

 int countRedBeads( n) {
if( n<.

int countRedBeads (int n);.

Test( sample_tests, should_pass_all_the_tests_provided).
{
cr_assert_eq( countRedBeads( 0 ), 0);.
cr_assert_eq( countRedBeads( 1 ), 0);.
cr_assert_eq( countRedBeads( 3 ), 4);.
cr_assert_eq( countRedBeads( 5 ), 8);.
}

Like this post? Please share to your friends:
Leave a Reply

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: