This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Author: Chris Niesel | |
# Class: Computer Science 2211A | |
# output the last argument passed to the script | |
# check if there are more than 0 argument | |
while [ $# -gt 0 ];do | |
# if current argument is the last one output it | |
if [ "$#" -eq 1 ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Author: Chris Niesel | |
# Class: Computer Science 2211A | |
echo "Number of arguments passed: $#" | |
X=0 # var used for while loop that increments every run | |
while [ $# -gt 0 ];do # check if we have more arguments | |
# check if $X number is even if so, print it | |
if [ `expr $X % 2` -eq 0 ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obelix[279]% sh nums.sh ; echo $? | |
Usage: nums option input-file | |
1 | |
obelix[280]% sh nums.sh 0; echo $? | |
Usage: nums option input-file | |
1 | |
obelix[281]% sh nums.sh 5; echo $? | |
Usage: nums option input-file | |
1 | |
obelix[282]% sh nums.sh 0 numbersfile; echo $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Author: Chris Niesel | |
# Class: Computer Science 2211A | |
# check if there are 2 arguments | |
if [ "$#" -eq "2" ] | |
then | |
# check if file doesn't exist | |
if [ ! -f "$2" ]; then | |
echo "input-file not found" | |
exit 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Author: Chris Niesel | |
# Class: Computer Science 2211A | |
# get number from user | |
echo "Enter a number: " | |
read i | |
x=0 # loop iterator value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Author: Chris niesel | |
#include <stdio.h> | |
int main(void) { | |
int currency[] = {20,10,5,2,1}; | |
int amount = 59; | |
int num; | |
int i =0; | |
for(i;i<5;i++){ | |
if(currency[i]<=amount) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Author: Chris Niesel | |
// Class: 2211A | |
#include <stdio.h> | |
/* | |
Method: pay_amount | |
input: int dollars, int *twenties, int *tens, int *fives, int *toonies, int *loonie | |
purpose: determine the best way to change an amount into bills / coins | |
returns: nothing. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// author: chris niesel | |
// class: 2211 | |
#include <stdio.h> | |
#define SIZE 99 // maximum size of magic square | |
void genSquare(int size, int square[SIZE][SIZE]){ | |
// set starting coordinates | |
int row = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// author chris niesel | |
// class compsci 2211 | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
void initrandom(){ | |
srand((float) time(NULL)); | |
} | |
float genRandom(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// author chris niesel | |
// class compsci 2211 | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <math.h> | |
/* | |
Method: initrandom | |
input: nothin |
OlderNewer