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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:24:06+00:00 2026-05-23T09:24:06+00:00

I am new to stackoverflow as am new to programming, yet am not really

  • 0

I am new to stackoverflow as am new to programming, yet am not really a ‘professional and enthusiast programmer’. Enthusiast maybe but not professional…

In a part of some beginner code of mine i have a two dimensional array diff[i][j], where the value is zero wherever i==j. I am trying to get the smallest value in each row but not the zero value…

the part of the code (under construction) that searches the smallest of the first row is:

i=1;
double smallest;
for ( j=1 ; j<=n ; j++ )
{ 
     smallest = diff[i][j];

     if ( j!=i && diff[i][j] < smallest ) 
         smallest = diff[i][j];
}

printf("\n %lf\n", smallest);

however, the result is always the biggest number not the smallest. Anyone knows why??

P.S. I’d be thankful for any suggestion or comment of dealing with stackoverflow.com and the way i asked my question, since am new here… thank you in advance…

EDIT
after the answers below, i decided to make the i=1 a special case and make two separate functions for both cases… however, when i try to assign j to other variable i failed… in the previous code:

if (j!=i && diff[i][j]<smallest) {smallest=diff[i][j]; d=j}

declared d previously and everything… when i print d it prints a random number >maybe the memory location content… tried for debugging to assign an initial value – with the declaration – and when printing it came out the initial value… the point is i want d to hold the column where the smallest value is… how can i acheive that??

  • 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-23T09:24:06+00:00Added an answer on May 23, 2026 at 9:24 am

    You never initialize smallest

    i=1;
    double smallest = diff[1][2]; // initialize it to a non-diagonal element in the column
    for (j=1; j<=n; j++)
        if (j!=i && diff[i][j]<smallest){
            smallest=diff[i][j];
        }
    printf("\n %lf\n", smallest);
    

    EDIT:

    You also seem to have { smallest= diff[i][j]; .. } in your code that overrides the value of smallest each iteration. I removed it in my answer.

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

Sidebar

Related Questions

I'm fairly new to programming but I've been reading some interesting discussions on StackOverflow
I'm sort of new to Windows GUI programming. I got some code which works
I am new to C, but not to programming. I have been roped into
StackOverflow'ers, I realize the new @mentions is a very new feature to facebook, but
I am new to stackoverflow and Java programming. I was practicing inheritance with sample
I'm new to both OpenCv and StackOverflow, and almost new to Android programming so
I wonder if this has its place on StackOverflow, but since it IS programming-related,
I'm creating a movies website, IMDB.com like.. I'm really new to PHP and programming
Not strictly a programming question, but I was programming at the time and couldn't
This might seem like a silly question, but after asking some questions on stackoverflow

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.