logoISU  

CS456 - Systems Programming

Spring 2026

Displaying ./code/h1/sequence.c

/*

sequence.c - print a sequence of numbers

we're implementing a simplified version of the "seq" command from linux. 

this takes two arguments, a starting point and an ending point, and prints 
every number from start to finish

Ex:
> ./sequence 3 8
3
4
5
6
7
8

*/

//put all needed header files here
#include <stdio.h>
#include <stdlib.h>


int main (int argc, char **argv){

  // user only provided name of command, so just print usage statement.
  if(argc < 2){
    fprintf(stderr, "Usage: %s start end\n", argv[0]);
    return -1;
  }

  //declare variables for numbers;
  int start, end;

  //use atoi to convert strings to decimal numbers
  start = atoi(argv[1]);
  end = atoi(argv[2]);

  //starting with the start value, loop until the end value.
  for(int i = start; i <= end; i++)
	printf("%d\n", i);

  return 0;



}