Thread: Program to read and then write the elements in an array using functions.

  1. #1
    Registered User
    Join Date
    Jan 2016
    Posts
    2

    Question Program to read and then write the elements in an array using functions.

    Code:
    #include <stdio.h>
    
    read( int x, int y)
    {
        for (x=0;x<10;x++)
        {
            for (y=0;y<3;y++)
            {
                scanf("%d",&a[x][y]);
            }
        }
    }
    
    
    write(int x,int y)
    {
        for(x=0;x<10;x++)
        {
            for (y=0;y<3;y++)
            {
                printf("The value at %d row and %d column is %d\n",x,y,a[x][y]);
            }
        }
    }
    
    
    main()
    {
        int a[10][3],i,j;
    
    
        printf("Enter the values of the array.\n");
    
    
        read(i.j);
        write(i,j);
    
    }

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Did you have a specific question?

    If your code is not compiling, you should post all the warning and error message you receive when you compile.

    If it is compiling, you should explain how the actual output differs from the expected output.

    If you want to write values to (or read values from) your array in those functions, you need to pass that array to those functions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read from txt and write in an external program
    By sombrancelha in forum C Programming
    Replies: 8
    Last Post: 06-01-2009, 09:04 PM
  2. C program file read/write help
    By BobDole11 in forum C Programming
    Replies: 5
    Last Post: 10-13-2008, 09:55 AM
  3. How to read and write an char array
    By Menno in forum C Programming
    Replies: 0
    Last Post: 06-17-2007, 06:17 AM
  4. Can I write & read file in same program?
    By chad03 in forum C Programming
    Replies: 2
    Last Post: 08-04-2003, 08:39 AM
  5. Using write() to print array elements
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 04-01-2002, 09:18 PM

Tags for this Thread