Chapter - 3: The Decision Control

Any year is entered through the keyboard, write a program to determine whether the year is a leap or not. Use the logical operators && and ||.


G
Sections
1
Exercises

A

B

C

D

E

F

G

H

I

J

K

1

2

3

4

5

6

7

8

9

10

11

13

#include<stdio.h>
#include<conio.h>
int main()
{
	int yer;
	
	printf("Enter a year : ");
	scanf("%d", &yer);
	
	if( ((yer % 4) && 1) == 0 )
		printf("\n\n%d is a leap year", yer);
		
	if( ((yer % 4) || 0) == 1 ) 
		printf("\n\n%d is not a leap year", yer);
	
	getch();
	return 0;
}

© 2020 Garbage Valuegarbage value logo