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 6859817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:19:51+00:00 2026-05-27T02:19:51+00:00

I’m trying to make a C function which will ask the user to enter

  • 0

I’m trying to make a C function which will ask the user to enter in a number (44634329) and will scanf the number, save it to a variable , and will go through digit by digit, and figure out the largest number.

http://pastebin.com/tF7PVtvg – this is my project so far

void extractLargestDigit() {

int i;
i = 0;
int v;
v = 0;
int x;
x = 0;

printf("Enter an integer : ");
scanf("%d", &x);

    i = x % 10;
x = x / 10 % 10;

if(i >= x) { i = i; x = x / 10 % 10;}
if(x >= i) { i = x; x = x / 10 % 10;}
if(x = 0)  { i = i;}

Right here is where I’m trying to make the program loop so that it will continue to cycle through until x is equal to 0. I’m hoping that this will make i be the largest value in the number and will display it as such. I also have to display at what point the largest digit occurs , like in the number 542356976 , the right most 6 is in the 1st digit position, and the 9 is in the 3rd digit position, I need to display where the largest digit occurs in the number and have not quite figured that out

printf("\nThe largest digit : %d\n", i);
    printf("\nIts position : );


    return;
 }

Any help or insight would be awesome

  • 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-27T02:19:51+00:00Added an answer on May 27, 2026 at 2:19 am

    I would do it in a different way:

    void extractLargestDigit() {
    
        printf("Enter an integer : ");
        scanf("%d", &x);
        int max  = -1; // so it will always be less than any first digit
    
            while (x >0){
                int digit = X %10; //grab last digit
                x = x / 10;        //throw last digit away
                if (max < digit)       //if this digit is grater than current max...
                    max = digit;       //... update it!
        }
    
        return max;
    }
    

    This way, you loop through each digit in turn, and the greatest on will be in max varible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I need a function that will clean a strings' special characters. I do NOT
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

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.