Friday, October 30, 2009

Chap8[I]d

Write a program which performs the following tasks:
− initialize an integer array of 10 elements in main( )
− pass the entire array to a function modify( )
− in modify( ) multiply each element of array by 3
− return the control to main( ) and print the new array elements in main( )


2 comments:

  1. can u find error of my code? it works but it doesnot multiplies by 3 output is same as input:
    #include
    #include
    int modify(int *a[10])
    {
    int i, j, k;
    for(i=0;i<=9;i++)
    {
    k=*a[i];
    printf("\n");
    j=k*3;
    return j;
    }
    }
    main()
    {
    int *ten[10];
    int h;
    for(h=0;h<=9;h++)
    {
    printf("Enter element no.%d of array: ",h);
    scanf("%d",&ten[h]);
    }
    modify(&ten[10]);
    for(h=0;h<=9;h++)
    {
    printf("%d",ten[h]);
    }
    getch();
    }

    ReplyDelete
  2. Brother there are some errors in your code please try to corrext them

    ReplyDelete