Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7803471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:35:41+00:00 2026-06-02T01:35:41+00:00

Rewrite this program to use a function for each of the ways you’re printing

  • 0

Rewrite this program to use a function for each of the ways you’re printing out things. Try to pass pointers to these functions so they work on the data. Remember you can declare a function to accept a pointer, but just use it like an array.

How do you do? I have c code which are with for looping printing out index array and pointer index. Here right code without function:

       int main(int argc, char * argv[])
       {

       int number[] = {123, 456, 789};
       char *strchars[] = {
         "ABC", "DEF", "GHI"
       };

       int count = sizeof(number) / sizeof(int);
       int i = 0;

       for(i = 0; i < count; i++) {
          printf("%s has %d \n", strchars[i], number[i]);
       }

       // with pointers

       int *po_number = number;
       char **po_strchars = strchars;

       // loop with pointiers

       for(i = 0; i < count; i++) {
           printf("%s has %d \n", *(po_strchars+i), *(po_number+i));
       }
       return 0;
    }

But i need use for each of the ways printing out things. But I can’t figure out. Here my code with functions but without pointer and chars only integer. Give me how to make it right:

    #include <stdio.h>
    // void print_arg(int a[], int b[]);

    // now it right?

    // void print_arg(int a[], int b[])

    void print_arg(int a, int b);

    // or now it right?

    void print_arg(int a, int b)
    {
          int a;
          int b;
          int count = sizeof(a) / sizeof(int);
          int i = 0;
              //and it
          for(i = 0; i < count; i++) {
              printf("%d and %d\n", a[i], b[i]);
          }
    } 

    int main(void)
    {
          int number[] = {22, 32, 22, 82, 2};
          int strchars[] = {12, 12, 12, 12, 12};

          int count = sizeof(number) / sizeof(int);
          print_arg(number[], strchars[]);

          return 0;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:35:43+00:00Added an answer on June 2, 2026 at 1:35 am

    Are you trying to write a function that will print the data?

    void print_array_args(int a[], int b[], int count)
    {
      int i = 0;
      for(i = 0; i < count; i++) {
        printf("%d and %d\n", a[i], b[i]); // You can treat arrays as arrays...
        printf("%d and %d\n", *(a+i), *(b+i)); // ... or as pointers.
      }
    } 
    
    void print_pointer_args(int *a, int *b, int count)
    {
      int i = 0;
      for (i = 0; i < count; i++) {
        printf("%d and %d\n", a[i], b[i]);     // You can treat pointers as arrays...
        printf("%d and %d\n", *(a+i), *(b+i)); // ... or as pointers.
      }
    } 
    
    
    int main(void)
    {
      int number[] = {22, 32, 22, 82, 2};      // You can declare an array...
      int *strchars = malloc(5 * sizeof(int)); // ... or a pointer
    
      int i;
      for (i = 0; i < 5; i++) {
        strchars[i] = 12;      // You can initialize as an array....
        *(strchars + i) = 12;  // ... or as a pointer
      }
    
      int strchars[] = {12, 12, 12, 12, 12};
      int count = sizeof(number) / sizeof(int);
      print_array_args(number, strchars, count);
      print_pointer_args(number, strchars, count);
      return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to rewrite this query and I'm not allowed to use a subquery.
How would I rewrite this query to be performant by executing the SQL function
How can I rewrite this code to coffeescript: $('.delete_action').click(function(event) { $.get('/delete_action?name=' + event.target.name +
I want to rewrite the cp command of Linux. So this program will work
I thought I would rewrite this question (same iteration). The original was how to
how I can rewrite this: for (int i = 0; i < numberOfSpaces; i++)
How can I rewrite this code to check for all characters including the swedish
I am trying to rewrite this url: http://www.sample.com/product_guide&product_name=waht&product_type=dog-clipper to: http://www.sample.com/waht/dog-clipper I am using this
How can I rewrite this query to Doctrine DBAL query or better to createQuery()
I need rewrite this url http://adresa.com/article.php?act=view&id=1113 to http://adresa.com/view/1113 I make it with mod_rewrite in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.