Lab Task 3.docx - Ngoc Phuong Van Nguyen 101874442 Week3 1...

This preview shows page 1 - 5 out of 6 pages.

Ngoc Phuong Van Nguyen 101874442 Week31.Task 3.1:Source code: #include <stdio.h>int main(){int a;srand(time(NULL));a= rand()%6 +1 ;printf ("Your number is %d\n", a);if (a%2 == 0) printf ("You win.\n");else printf ("You lose.\n");return 0;}Screen Shot:
2.Task 3.2:Source Code:#include <stdio.h>int main(){int k=1,a,sum=0;srand(time(NULL));for (k=1; k<=5; k++){a= rand()%6 +1 ;printf ("Your results are: %d\n",a);sum = sum+a;}printf ("Total sum is: %d\n", sum);if (sum%2 == 0 && sum > 15){printf("You win.\n");}elseprintf ("You lose.\n");return 0;}Screen Shot:
3.Task3.3:Source Code:#include <stdio.h>

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture