Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why appear random number at the end

+2 votes
asked Oct 17, 2020 by E Alkindi (140 points)
int main()
 {  
   int calclus, fyear ;
  do{
      printf (" enter first year\n");
      scanf ("%d" , &fyear);

     
     if (((fyear % 4 == 0) && (fyear % 100!= 0)) || (fyear%400 == 0))
      printf("%d is  a leap year", &fyear);
     else
      printf( "%d is  not a leap year", &fyear);
  }while (fyear < 999 );
 

   return 0;
}

1 Answer

0 votes
answered Oct 21, 2020 by LiOS (6,420 points)
In printf, you only reference the variable, not the address of the variable i.e. fyear not &fyear.

#include <stdio.h>

int main(){
    
    int calclus, fyear;
    
    do{
        printf (" enter first year\n");
        scanf ("%d" , &fyear);
        
        if (((fyear % 4 == 0) && (fyear % 100!= 0)) || (fyear%400 == 0))
            printf("%d is  a leap year", fyear);
        else
            printf( "%d is  not a leap year", fyear);
    }
    while(fyear < 999);
    
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...