UNIX or Linux code

Anyone know unix or linux code and can help me write 3 simple programs?

shell scripts?

c?

I g0tz dem sweet c0dez

#include<stdio.h>

int main()
{
printf("Hello World
");
return 0;
}

yea shell scripts, i’m taking a unix class during the winter term and its impossible to learn this code in such a short time. Its a whole semesters worth in 2 weeks.
this is what I have to do:

  1. Write a program that will allow a user to input as many numbers as the user wants (999 as the choice that ends the user input). The program will then respond:

Highest Number: Answer
Lowest Number: Answer
Sum of the numbers: Answer
Average of the numbers: Answer

  1. Create a Number guessing game. Have the computer pick a number from 0-60.
    Then allow the user to guess at the number until the user gets it right. (Hint you can use the seconds from the clock to get the number to guess). Please include the following:

a) Keep a counter of how many guesses were made, and then tell the user how many guesses it took.

b) As the user guesses, tell the user whether the guess is too high or too low.

  1. Write a program that will allow a user to type in a number, then the number will either count up to the number provided by the user or count down from that number. In addition, create a menu that will let the user choose which counter they wish to use. In both cases that counter will either count down to 0, or start counting from 0.

at first i was like, “oh my maybe its the same kinda class my buddy eric is taking” then i saw the username. lol. If I have some time tomorrow I will try to help you

Just so you guys know, the shell scripts must be written for sh/ksh

I am going out to dinner I will take a look at this when I get home.

“man ksh” should give you a good starting point.

thanks guys

im working on the first one now, so don’t do that one

Haha, almost done with the first.

Shell scripts are fun.

number 1 is complete and sent off

its already done

Damn you, just finished

I’m not going to do these for him, I don’t think that would help him in the long run. I was going to help him when he hit a wall.

he goes to school for construction management engineering, i doubt he will ever look back at this shit

Ah, how come he has to take this course then?

I’m gonna jump to 3 :wink:

Sent

Post up the code

lol I could do it in C++ and Perl… not shell script though :frowning:

heres the code for the first problem in case anyone wanted to see how its done

#!/bin/ksh

current_high=$1
current_low=$1
sum=0
for arg;do
sum=$(($sum+$arg))
if [ $current_high -lt $arg ] ; then
   current_high=$arg
fi

if [ $arg -lt $current_low ] ; then
   current_low=$arg
fi

done
avrg=$(($sum/$#))
print "Highest Number: "$current_high
print "Lowest Number: "$current_low
print "Sum of the numbers: "$sum
print "Average of the numbers: "$avrg