// 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 Tuesday 18 June 2019, 01:54:17 AM.

file: CodeReview.c


Back to top

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