How to convert code into a function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • royhoja
    New Member
    • Mar 2010
    • 1

    How to convert code into a function

    How do i convert the following code into a function? What parameters would be in the function?

    printingform(?? ?,???)

    Code:
    #include <stdio.h>
    #include <string.h>
    int main()
    {
    int i;
    //int j;
    int n;
    printf("Enter length and the list");
    scanf("%d", &n);
    int number[22];
    printf("It is :[");
    for (i=0;i<n;i++){
    scanf("%d", &number[i]);
    printf("%d\t",number[i]);
    }
    printf("]");
    printf("\n");
    }
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    If you don't know how to create seperate functions see here

    Anyways, what do you want to do in your function?

    Comment

    • whodgson
      Contributor
      • Jan 2007
      • 542

      #3
      What the moderator is saying is that it is difficult to turn code into a function if it is not clear what the function is meant to do. If line 8 made any sense it could have helped.

      Comment

      Working...