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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:03:24+00:00 2026-05-24T17:03:24+00:00

This program outputs 1. I could not understand how it outputs 1 as the

  • 0

This program outputs 1. I could not understand how it outputs 1 as the for loop will fail at a[2][3] which contains the value 12. So 12 will get assigned to k and the output will have to be 12.

#include<stdio.h>

int main()
{
    int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};
    int i,j,k=99;
    for(i=0;i<3;i++)
    {
        for(j=0;j<4;j++)
        {
            if(a[i][j]<k)
            {
                k=a[i][j];
                printf("%d\n",k);
            }
        }
    }
    printf("Res:%d\n",k);
    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-05-24T17:03:25+00:00Added an answer on May 24, 2026 at 5:03 pm

    The first time through the loop the if is evaluated as a[0][0] < k which is 1 < 99 which is true.
    The second time through he loop if the if is a[1][0] < k which is 2 < 1 which evaluates as false thus the value of k is not updated
    k is never reassigned another value, thus at the end k=1.

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

Sidebar

Related Questions

The output of the below program is 24. But I could not understand the
Can someone please explain why this program outputs 0x00000004? class AndAssignment { static void
Can anyone explain the output of this program and how I can fix it?
When I attempt to compile the output of this trivial lex program: # lex.l
I have this output when trying to debug Program received signal SIGSEGV, Segmentation fault
This program I'm doing is about a social network, which means there are users
I tried trial and error by tracing strings so I could understand the program
I understand things in here are value types and not referenced so the field
This question is not for the faint of heart and will be time consuming..
This program I use has it's own variables to set when you run it,

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.