Skip to content

Latest commit

 

History

History

0x01-variables_if_else_while

README 0x01. C - Variables, if, else, while

0. Positive anything is better than negative nothing

This program will assign a random number to the variable n each time it is executed. Complete the source code in order to print whether the number stored in the variable n is positive or negative.
  • You can find the source code here
  • The variable n will store a different value every time you will run this program
  • You don’t have to understand what rand, srand, RAND_MAX do. Please do not touch this code
  • The output of the program should be:
    • The number, followed by
      • if the number is greater than 0: is positive
      • if the number is 0: is zero
      • if the number is less than 0: is negative
    • followed by a new line

1. The last digit

This program will assign a random number to the variable n each time it is executed. Complete the source code in order to print the last digit of the number stored in the variable n.

  • You can find the source code here here
  • The variable n will store a different value every time you run this program
  • You don’t have to understand what rand, srand, and RAND_MAX do. Please do not touch this code
  • The output of the program should be:
    • The string Last digit of, followed by
    • n, followed by
    • the string is, followed by
      • if the last digit of n is greater than 5: the string and is greater than 5
      • if the last digit of n is 0: the string and is 0
      • if the last digit of n is less than 6 and not 0: the string and is less than 6 and not 0
    • followed by a new line

1. The last digit

This program will assign a random number to the variable n each time it is executed. Complete the source code in order to print the last digit of the number stored in the variable n.