Skip to content

Instantly share code, notes, and snippets.

@josefsalyer
Created February 6, 2013 03:16
Show Gist options
  • Save josefsalyer/4719944 to your computer and use it in GitHub Desktop.
Save josefsalyer/4719944 to your computer and use it in GitHub Desktop.
Remember to create a list of the steps using comments you want your program to perform so that you can keep track of your completeness as you go.
//
// main.c
// Loops
//
// Created by Curt on 2/5/13.
// Copyright (c) 2013 Curt. All rights reserved.
//
#include <stdio.h>
int main(int argc, const char * argv[])
{
//count backwards by 3 from 99 to 1
for (int x = 99; x > 0; x -= 3) // <-- see how I declared x's type as an int inside the loop? there's a reason.
{
//see what numbers are divisible evenly by 5
if (x % 5 == 0)
{
//tell me when you find one
printf("Found one! - %d.\n", x);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment