Sponsored Content
Full Discussion: basic math program 4 child
Top Forums Programming basic math program 4 child Post 30301 by WIntellect on Sunday 20th of October 2002 09:07:21 AM
Old 10-20-2002
Ok - I don't know C, but i know the groundwork to Perl - so here's one Perl solution:

Code:
#!/usr/bin/perl

print "\nHello Joe, how are you today? ";
chomp( $feelToday = <STDIN> );

print "\nI am happy you are $feelToday today.";
print "\nLet's do some math. What's your first number? ";
chomp( $firstNumber = <STDIN> );

print "\nWhat's your second number? ";
chomp( $secondNumber = <STDIN> );

$mathResult = $firstNumber + $secondNumber;
print "\nThe math result is $mathResult!\n\n";

Just put it in a script, make it executable and run it. Just make sure the first line points to the location of your Perl executable on your system!

Smilie
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Having trouble writing a basic shell program

Hello. I'm trying to write a shell script that will take files that have .tar, .tar.gz, .tar.Z, .gz, .Z and .zip file extensions and uncompress and unarchive them. The script should be able to take multiple arguments. So far I can write a script using the case command that will do this but it will... (3 Replies)
Discussion started by: SeanWuzHere
3 Replies

2. Shell Programming and Scripting

writing math testing program

Can anyone create a program that would test the math skills of the user. Assume that it would test integer addition, The program should ask the question,collect the integer response, evaluate and notify the user if their answer was correct or incorrect. I would assume integers in the range... (5 Replies)
Discussion started by: ccp
5 Replies

3. Programming

parent not waiting until child complete executing another program through execl()

Hi, I am calling a program that greps and returns 72536 bytes of data on STDOUT, say about 7000 lines of data on STDOUT. I use pipe from the program am calling the above program. Naturally, I execute the above program (through execl() ) throught the child process and try to read the... (4 Replies)
Discussion started by: vvaidyan
4 Replies

4. Programming

Basic multithreaded program

I'd like to write a program (I'm flexible on language; C/C++ was my original idea but a scripting language would probably be better) that runs hundreds of programs, but only N = 4 (say) at a time. The idea is to keep all the cores on a multicore machine busy. How can I do this? In particular,... (6 Replies)
Discussion started by: CRGreathouse
6 Replies

5. HP-UX

Program monitor on BT-Basic

Hi, The "program monitor" command in BT-Basic prompt you for a user name and a password. How can I grant access only to certain users ? Thank you. (0 Replies)
Discussion started by: fosiceanu
0 Replies

6. What is on Your Mind?

Any ideas on child-control program

My auntie told me that she has been suspecting that her little kids are looking at some "illegal" sites online. She put a free web blocker on the computer, but they might be finding loopholes. She wanna install some child-control program to see what's going on. There are so many since I searched... (5 Replies)
Discussion started by: Bluerosen
5 Replies

7. Homework & Coursework Questions

Need help with Basic Unix Program

I am a newbie to UNIX. I'm learning UNIX on my own, just trying to get the jerk of how things work in UNIX environment. I am familiar with Windows environment. Can anyone pls write simple 'envprint' programs to : 1) List all the environment Information (using the -l or --l options) 2) ... (1 Reply)
Discussion started by: agup17
1 Replies

8. Shell Programming and Scripting

Perl math program

I have this math program on Perl and when I run it one of the math problems that comes up is 0/0 and perl makes the answer 4. How can I program perl to not include numbers /0? What I have for the division portion is: $solution = $num1 * $num2; ($solution, $num1) = ($num1, $solution); $question... (2 Replies)
Discussion started by: germany1517
2 Replies

9. Homework & Coursework Questions

Log file analyzer, super basic sh program

Hello! I'd like some help with this assignment. 1. The problem statement, all variables and given/known data: 1)Write a shell script that can uses two types of files as inputs, apache.log and apache.error.log 2)Make it so that you can switch between the two file types 3)Make it so that the... (5 Replies)
Discussion started by: malfiory
5 Replies
fork(2) 							System Calls Manual							   fork(2)

Name
       fork - create a new process

Syntax
       #include <sys/types.h>
       #include <unistd.h>

       pid = fork()
       pid_t pid;

Description
       The  system  call causes creation of a new process.  The new process (child process) is an exact copy of the calling process except for the
       following:

       o    The child process has a unique process ID.

       o    The child process has a different parent process ID (that is, the process ID of the parent process).

       o    The child process has its own copy of the parent's descriptors.  These descriptors reference the same underlying objects, so that, for
	    instance,  file  pointers  in file objects are shared between the child and the parent, so that a on a descriptor in the child process
	    can affect a subsequent read or write by the parent.  This descriptor copying is also used by the shell to	establish  standard  input
	    and output for newly created processes as well as to set up pipes.

       o    The child processes resource utilizations are set to 0.  For further information, see

Return Values
       Upon  successful  completion,  returns  a  value  of  0	to the child process and returns the process ID of the child process to the parent
       process.  Otherwise, a value of -1 is returned to the parent process, no child process is created, and the global variable errno is set	to
       indicate the error.

Diagnostics
       The system call fails and no child process are created under the following conditions:

       [EAGAIN]       The system-imposed limit {PROC_MAX} on the total number of processes under execution would be exceeded.

       [EAGAIN]       The system-imposed limit {CHILD_MAX} on the total number of processes under execution by a single user would be exceeded.

       [ENOMEM]       There is insufficient swap space for the new process.

See Also
       execve(2), wait(2)

																	   fork(2)
All times are GMT -4. The time now is 02:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy