// Some Code for Review
// Marc Chee, March 2019

#include <stdio.h>

int main(void) 
{
    int num;

    // Read in the number.
    printf("Please enter an integer: ");
    scanf("%d", &num);

    printf("You entered ");
    if (num <= 0) 
    {
        printf("a number less than one");
        return 0;
    } 
    if (num == 1) 
    {
        printf("one.\n");
        return 0;
    } 
    if (num == 2) 
    {
        printf("two.\n");
        return 0;
    } 
    if (num == 3) 
    {
        printf("three.\n");
        return 0;
    } 
    if (num == 4) 
    {
        printf("four.\n");
        return 0;
    } 
    if (num == 5) 
    {
        printf("five.\n");
        return 0;
    } 
    printf("a number greater than five.\n");
}

Resource created Monday 04 March 2019, 11:33:13 PM, last modified Monday 04 March 2019, 11:36:19 PM.

file: CodeReview.c


Back to top

COMP1511 19T1 (Programming Fundamentals) is powered by WebCMS3
CRICOS Provider No. 00098G