Ask Question
14 September, 00:13

How do I write a program in Pascal that finds the index of the minimum number of an array (using Function) and replaces it to a number inputted from the keyboard? (Input and output of the array is a Procedure).

+3
Answers (1)
  1. 14 September, 02:45
    0
    program arraysminfinder;

    procedure minreplace ();

    var

    no: array [1 ... 10] of integer; (*no is an array of integers, 10 in all * )

    a: integer = 0;

    i: integer = 0;

    c: integer = 0;

    k: integer=0;

    N: integer=0;

    begin

    ( * We need to first initialize the array no with 0 values * )

    for a : = 1 to 10 do

    no[a]:=0;

    c:=no[1];

    for a : = 1 to 10 do

    begin

    if (no[i]
    begin

    c:=no[i];

    k:=i;

    end

    else

    begin

    i:=i+1;

    end

    end;

    writeln ('Enter the new number:');

    read (N);

    no[k]:=N;

    for a : = 1 to 10 do

    begin

    writeln ('The array elements are:', no[a]);

    end;

    end;

    begin

    end.

    Explanation:

    The program is as above. I have used a function, a for loop, an array of integers, and the if then else ladder for getting the desired output as mentioned in the program. If in case you want procedure for input and output, create a procedure like:

    procedure replacenum () : integer;

    Begin

    writeln ("Enter the new number:" N);

    no[k]:=N;

    for a : = 1 to 10 do

    writeln ("The array elements are:"no[a]);

    end.

    Similarly you can make a procedure for input.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “How do I write a program in Pascal that finds the index of the minimum number of an array (using Function) and replaces it to a number ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers