Challenge 2

+1 Manisha Kohli · October 13, 2015
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
int main()
//roll 3 dice

int a=0,b=0,i,diceRoll;
char choice[1];

for(i=0;i < 3;i++)
  diceRoll=( rand()%6 )+1;


  printf("Dice rolled %d\n",diceRoll);
printf("sum of all the numbers: %d\n", a);
 printf("will the next row be higher(h), lower(l) or same(s):");
for(i=0;i < 3;i++)
  diceRoll=( rand()%6 )+1;


  printf("Dice rolled %d\n",diceRoll);


    printf("u rock\n");
        printf("y dude\n");

return 0;


Post a Reply


Oldest  Newest  Rating
0 Linguist Llama · October 15, 2015
How many characters can you store in choice?

char choice[1];
printf("%zu\n", sizeof choice);

How many characters are required to store "h", "l" or "s"?

printf("%zu\n", sizeof "h");
printf("%zu\n", sizeof "l");
printf("%zu\n", sizeof "s");
0 Manisha Kohli · October 18, 2015
printf("will the next row be higher(h), lower(l) or same(s):");

was used to make sure end user is aware that they have limited options
-1 Manisha Kohli · October 18, 2015
char choice[1]; meant 2 characters only ie if the user gives an input of h it will be "h\0" i.e 2 characters!!!
0 Linguist Llama · October 24, 2015
What is sizeof choice?
What is sizeof "h", sizeof "l" and sizeof "s"?
Do you see the problem?

You should be able to provide one word answers to my questions. It may be confronting to realise that you're wrong, but it is a necessary part of correcting your understanding. Stop making excuses for your education, and start learning, by providing one word answers to my questions.
0 Patrick Schwarz · December 12, 2015

What about mine? it works but I always do everything kinda sloppy and in a very long way, any critics are welcome xD
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator