i have

program p1032;
const  n=10;       num=4;
var      i:integer;
 a:array[1..n] of 1..n;
 procedure tipareste;
  var i:integer;
  begin
   for i:=1 to num do write(a[i],' ');
   writeln;
  end;
 procedure permuta(k:integer);
 var   i,x:integer;
  begin
  if k=1 then tipareste else begin
   for i:=1 to k do begin
    x:=a[i];a[i]:=a[k];a[k]:=x;
    permuta(k-1);
    x:=a[i];a[i]:=a[k];a[k]:=x;
  end;
 end;
end;
begin
 for i:=1 to n do a[i]:=i;
 writeln;
 permuta(n);
end.

This program is in Turbo Pascal Language i need the same program just in C Language
Thank you very much

Yet you expect C programmers to know Pascal and be interested in doing all of your work for you? Why not take this opportunity to learn C?

Edited 5 Years Ago by Narue: n/a

#include <stdio.h>
// prototypes for functions.
int tipareste (int a[]) ;
int permuta (int k) ;

int main(void)
{
    int i = 10, num = 4 ;
    for (i = 1; i <= n; i++)
    {
    }
return 0 ;
}

// Put your functions down here:
// Also, goto www.cplusplus.com and go through their tutorial for learning C. And then if you have any further questions after having done this, feel free to ask.

But basically, it looks like you have 2 functions which are being called in the main part of your program (procedures). You prototype the functions and add them at the end. Or just put them completely at the beginning and bypass the prototypes.

If you have any good links for Turbo Pascal, that would be cool.

Edited 3 Years Ago by Dani: Formatting fixed

Yeah, it looks like your corresponding main function for C begins at line 22 of your posted code and ends on line 26 appropriately with the word 'end.'

And it looks like you have two functions tipareste and permuta which are at the beginning of the program. And I'm guessing that you have a couple of constants n and num. You can declare those before the main statement in C using define statements. But for as simple as this program is, you could probably just include them after the main statement as I did.

But the main part of the program calls the permuta function which in turn calls the tipareste function.

This article has been dead for over six months. Start a new discussion instead.