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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:46:44+00:00 2026-06-12T15:46:44+00:00

I am trying to write a code for a problem in C. The code

  • 0

I am trying to write a code for a problem in C. The code is as follows:

#include<stdio.h>
int cop(int a,int b)
{
    int c,d,e,f,g;
    if(a>b)
    {   
        c=a;
        a=b;
        b=c;
    }
    while(c!=0)
    {
        c=b%a;
        b=a;
        a=c;
    }
    return b;
}

int main()
{
    int i=1, j=1, k, a, b, c, d, e, f, g=1;

    scanf("%d",&k);
    int q=0;
    for(q=k;q>0;q--)
    {
        scanf("%d",&a);
        while(g==1)
        {
            b=j+i;
            i=j;
            j=b;
            g=cop(j,a);
            printf("%d\n",g);
        }
        printf("%d %d\n",g,j);
        j=1;i=1;g=1;
    }

return 0;
}       

When I give input as 3 3 5 161 it was printing

1
3
3 3
1
1
5
5 5
1
1
1
1
1
7
7 21

and when i comment out the statement printf("%d\n",g) and execute with the same input i get the output as follows:

3 3
5 3
161 3

So, my doubt is why I am not getting:-

3 3
5 5
7 21
  • 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-12T15:46:45+00:00Added an answer on June 12, 2026 at 3:46 pm
    foo.c: In function 'cop':
    foo.c:4: warning: 'c' may be used uninitialized in this function
    

    Does this help?

    You’re depending on an uninitialized value in your function (in some cases). This means that the extra call to printf could dirty a register or a stack value and that will change how your function behaves.

    Strictly speaking it’s an undefined behavior and you just got a lesson on how undefined behavior can look like – unrelated function calls change how the undefined behavior behaves.

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

Sidebar

Related Questions

Problem: I am trying to write an app that executes some code when the
I'm trying to make a deliberate effort to write code that follows proper convention,
I m trying write code that after reset set up rrpmax as 3000. It
I'm trying to write code in my controller that when run, will create a
I am trying to write code for getting my cords on the mobile. I
I'm trying to write code that will load an image from a resource, and
I've been trying to write code that loads a .png file, attaches hotspot information,
Alright, here I am again trying to write code from scratch and I can't
Trying to write a code at the moment that basically tests to see if
I'm trying to write a code to actually sort my array in an ascending

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.