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

  • Home
  • SEARCH
  • 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 6927583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:04:27+00:00 2026-05-27T11:04:27+00:00

I need to write a program, that will ask a user to enter a

  • 0

I need to write a program, that will ask a user to enter a number of how many ints they would like to enter.. so the output would look like

Enter number of Ints (must be greater then 1)

and they would input a number between 2 – infinity (if they really wanted to go that far)

at that point i would scanf that number and set it to a variable

now with that number, i want to run a for loop to ask them to begin entering their Ints

for (count = 0; count < numofInts; count++)
{
    printf("    Enter an integer: ");
   scanf("%d", &Number);
}

the problem im having is that i need to make sure that it records every number that they enter, so i need to have those values stored to an array, but the number of elements of the array must be dynamic so that it can change depending on the numofInts, I’m supposed to use Malloc() to create a dynamic memory allocated space, and i understand that it creates a variable with a memory space of what ever i set the malloc to, but i don’t know how to store a series a variables to that space, and then call them back as i need them.

The end result of the program is supposed to take a number like 123456789, and cycle through the number storing the intergers as the “largest” int, and then spit out which int is the largest, so like x = 1234567890, x % 10, x = 0, largest = x, x / 10, x % 10, x = 9, if x > largest, largest = x, and just loop that till it cycles through the whole number, and store that number at the very end. I have that part down, but because i have to take a series of numbers and run this loop for all of those numbers, i need to be able to store and recall those values and place them in the loop to be able to store the largest digits of those numbers

any help with this problem would be greatly appreciated, i just have not been able to figure out how to use malloc or to create a dynamic array and most of the tutorials ive read online or watched from youtube are about C++ and i need to do this with just C…

http://pastebin.com/PZyvEQ4J

what i have so far

  • 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-05-27T11:04:28+00:00Added an answer on May 27, 2026 at 11:04 am

    After you read numInts, you allocate the array like so:

    int* arr = malloc(numInts*sizeof(int));
    

    Now you populate the array with your already existing function and assigning the values read to the array.

    I’m not going to give you a full solution, since this is homework and wouldn’t help you, but you access the i‘th element of the array with the [] operator:

    arr[i];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a javascript program that will ask the user to enter
Write a Python program that will ask the user to enter a string of
I need to write a program that will take a existing local windows user,
I need to write a C program that will compare the number of digits
I need to write a C program that will allow me to read/write files
I'm needing to write a program (C#) that will allow the user to create
Hey, I need to write a program for OSX that will cause my macbook
I need to write a server program that will open and keep 5 live
I need to write a delegate for a multi-threaded program that will enable/disable a
I need to write a program that will communicate with other .NET programs ...

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.