Thread: Counting 1-50 and pointing out odd and even numbers

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User juliette's Avatar
    Join Date
    Sep 2012
    Location
    Norway
    Posts
    2

    Counting 1-50 and pointing out odd and even numbers

    Hello!

    I've just started an introduction course in C programming at the University. I am currently struggling on the last exercise of an mandatory assignment.

    Its probably some basic stuff, but we were asked to make a program that counts from 1-50, which i have following code for;

    Code:
    #include <stdio.h>
    
    int main(void)
    {
    int i;
    
    for (i=0; i <= 50; i=i+1)
    
    
    {printf("%d\n", i);
    }
    This code works just fine, but the follow-up question is giving me a headache. We are asked to make the program to point out if the numbers are even or odd (with an "if" statement!).

    Example:
    1 is an odd number
    2 is an even number
    .... etc

    Hope you are able to help

    edit: Sorry about some misspellings, the assignment isnt given in english.
    Last edited by juliette; 09-13-2012 at 10:27 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting random numbers using pointing arrays.
    By jFran in forum C Programming
    Replies: 8
    Last Post: 05-10-2011, 01:56 PM
  2. Counting Digits & Numbers
    By yacek in forum C Programming
    Replies: 4
    Last Post: 10-06-2010, 08:44 PM
  3. Counting Numbers in Array, not counting last number!
    By metaljester in forum C++ Programming
    Replies: 11
    Last Post: 10-18-2006, 11:25 AM
  4. Counting Occurrance of Numbers
    By dat in forum C Programming
    Replies: 6
    Last Post: 11-03-2002, 02:11 PM
  5. counting even numbers
    By slamit93 in forum C++ Programming
    Replies: 5
    Last Post: 04-24-2002, 01:54 PM