Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Michael Bean's Spring 2017 Lab 3 v1.1
//gcc 5.4.0 #include <stdio.h> //Problem: //We would like implement a C program that reads an input a year and checks if it is a leap year. //Design an algorithm that checks whether a year is a leap year. A leap year: //The year is evenly divisible by 4; //If it can be evenly divided by 100, it is NOT a leap year, unless it is also evenly divisible by 400. Then it is a leap year. //Write a C program that implements your algorithm. (Due next lab). //Pseudocode //Start Program: // Int inputyear // READ inputyear // IF (inputyear%4==0 && inputyear%100!=0) // { // THEN PRINT "inputyear is a leap year" // } // ELSE IF (inputyear%4==0 and inputyear%100==0 and inputyear%400==0) // { // THEN PRINT "inputyear is a leap year" // } // ELSE // { // THEN PRINT "inputyear is not a leap year" // } //End Program: int main(void) { int inputyear; int a; a=4; int b; b=100; int c; c=400; scanf("%d",&inputyear); int check1; check1=inputyear%a; // printf("check1=%d\n",check1); int check2; check2=inputyear%b; // printf("check2=%d\n",check2); int check3; check3=inputyear%c; // printf("check3=%d\n",check3); if(check1==0 && check2!=0) { printf("%d is a leap year! :)",inputyear); } else if(check1==0 && check2==0 && check3==0) { printf("%d is a leap year! :)",inputyear); } else { printf("%d is not a leap year! :(",inputyear); } }
run
|
edit
|
history
|
help
0
Programação em C, testes
Sumit
The endless numbers.
A_141124Burbuja
merge two dice clay to head sport green globe attacked me seven of prime minister fired
BigInteger maxMinSum
MatrixMul_shortxshort
18BCE2182 LAB FAT-2-A-ii
MATRIZ DE CADENAS
UserDefinedDataType_pointer1