Questions tagged [subroutine]

A subroutine (e.g. procedure or subprogram) is a portion of code within a larger program, which performs a specific task and can be relatively independent of the remaining code. The syntax of many programming languages includes support for creating self contained subroutines, and for calling and returning from them. They are in many ways similar to functions, but usually have side-effects outside of the simple "return value" that functions return.

1255 questions
-2
votes
1 answer

Is subroutine executed without stack? Justify your answer with valid arguments

Is subroutine executed without stack? Justify your answer with valid arguments
-2
votes
1 answer

How can I write a Perl function that can generate a random DNA sequence

I want to write a Perl subroutine using rand() function that generates a random DNA sequence of specified length n. The length n of the sequence is passed as an argument to the subroutine. I would appreciate if someone could help me out as I am a…
-2
votes
1 answer

Use go routine to initialize multiple services

Trying to familiarize myself with subroutines and Go overall, and I'm trying to write a script that will basically start up all the services of my django app with sync.WaitGroup and keep them running until i manually kill the Go script, which is why…
mcbrandt13
  • 46
  • 6
-2
votes
3 answers

Handle multiple arguments to a Perl subroutine

As i have read ,"There’s another problem with this subroutine.This subroutine works properly only if called with exactly two Excess parameters are ignored—since the subroutine never looks at $_[2] " but when I passed multiple arguments its…
-2
votes
1 answer

(M68k) Why is my value not getting passed into D0?

So I am writing a program and subroutine where this is basically the pseudocode. int findmin(int* vals, int count){ if(count == 1){ return vals[0]; }else{ int minrest = findmin(vals+1,count-1); if…
-2
votes
2 answers

Perl Sub routine to get the square of a number

I am trying to write a subroutine to demonstrate getting a subroutine of a number as a function in Perl. I have no idea how to use the @_ operator in perl #!/usr/bin/perl use strict ; use warnings ; my $number = $ARGV[0] ; if (not defined $number)…
capser
  • 2,442
  • 5
  • 42
  • 74
-2
votes
1 answer

How do I write a Perl unit test for a method with a hash argument?

This subroutine will fetch the API host name from the environment by applying a regex on it. Parameters : environment (mandatory) - http://m5devacoe01.gcsc.att.com:8174/ Returns : host :…
-2
votes
2 answers

perl: subroutine returns 0 instead of specified array

I have a hash of hashes like this: my %HoH = ( flintstones => { 1 => "fred", 2 => "barney", }, jetsons => { 1 => "george", 2 => "jane", }, simpsons => { 1 => "homer", 2 =>…
user8548813
-2
votes
5 answers

Create a function that return the pow b^e

I have to create a function that return the value of b^e. This is what I have done: #include #include int funzione_potenza (int b, int e); int main () { int b, e, potenza; printf("Inserisci la base: "); …
Teorema
  • 83
  • 6
-2
votes
1 answer

returning arrays from subroutines in perl and using them in another subroutin

Hi I´am trying to learn Perl. I have a problem with creating an array and using references to use it in another subroutine. Sample code: #!/usr/bin/perl use strict; use warnings; sub test { my @a = ("a","b","c"); return \@a; } # code just…
-2
votes
1 answer

Error: "The leftmost part-ref in a data-ref can not be a function reference."

I am trying to write a FORTRAN subroutine for ABAQUS that would modify the seepage coefficient and thus the flow depending on whether there is contact on the surface. In order to do so I need 2 subroutines URDFIL to retrieve the node data and FLOW…
-2
votes
1 answer

I am trying to modify a method that returns an error string so that it can accept a hash in Perl

Here is the current method: sub new { my ($package, $message) = (shift, shift); my %params = @_; return bless { message => $message, %params }, $package; } This method returns basically an error string , but I want to modify it so it…
Paul Russell
  • 179
  • 10
-2
votes
1 answer

How can I read in a variable/value which is a runtime parameter that is inside a constant list of hashes?

I have tried putting the variables in the string but it reads as blank when I run the program. Here is an example of what I'm working with: use constant { #list will contain more errors ERROR_SW => { errorCode => 727, …
-2
votes
1 answer

fortran: how to pass a null pointer to a subroutine, in which it will be defined and returned

I want to have a small subroutine to make a duplicated copy of a pointer, which is already allocated /defined. I have the following test code: implicit none real ,pointer :: x(:),y(:) real,target:: px px=2.02 allocate(x(10)) x=20.0 call…
Ting Lei
  • 91
  • 9
-2
votes
1 answer

Fortran expected a right parenthesis in expression at (1) - Derived types in a subroutine

I get the error "Fortran expected a right parenthesis in expression at (1)" when specifying a component of a declared type in a subroutine. The (1) appears underneath the second % in the assignment from a, b, c in the subroutine. What am I doing…
Steve
  • 109
  • 4
1 2 3
83
84