+ 1

LEAP YEAR USING WHILE LOOP

I am finding it difficult to proceed of how to do using while loop? If anybody know please answer

8th Sep 2021, 8:27 AM
Abhishek
Abhishek - avatar
10 Respostas
+ 4
See Abhishek this is using while loop and for loop, on demand of you, if you found any difficulty let me know!!! https://code.sololearn.com/cPsNKU6UkvN0/?ref=app https://code.sololearn.com/cAK041gS8TUA/?ref=app
8th Sep 2021, 9:06 AM
Saurabh
Saurabh - avatar
+ 4
Show your code, where has been you stuck? and why you need to do with while loop? when it can be done by if-else statement
8th Sep 2021, 8:33 AM
Saurabh
Saurabh - avatar
+ 3
Abhishek #include<stdio.h> int main() { int m; printf("Enter a year:"); scanf("%d",&m); while(1) { if(m%100 == 0){ if(m%400 == 0){ printf("leap year"); break; } else{ break } } else if (m%4 == 0){ printf("leap year"); break; } else{ break; } } return 0; }
8th Sep 2021, 8:49 AM
Abhay
Abhay - avatar
+ 2
Abhishek it is doing with while loop only . Maybe you want to add more details so we can understand what exactly you are looking to do
8th Sep 2021, 9:05 AM
Abhay
Abhay - avatar
+ 1
Thank you @Saurabh Kumar Yadav I got it
8th Sep 2021, 9:14 AM
Abhishek
Abhishek - avatar
+ 1
Inside the wile loop body you can repeat asking the user for input and use if statement to check if the given user input is a leap year or not.You have to set while condition to true :while True....
8th Sep 2021, 9:45 AM
HBhZ_C
HBhZ_C - avatar
0
Because teacher has said to do with while loop that's why
8th Sep 2021, 8:41 AM
Abhishek
Abhishek - avatar
0
#include<stdio.h> int main() { int m,i=1; printf("Enter a year:"); scanf("%d",&m); while (i==m) { i%4==0; printf("leap year"); } return 0; }
8th Sep 2021, 8:41 AM
Abhishek
Abhishek - avatar
0
I can't know how to proceed
8th Sep 2021, 8:42 AM
Abhishek
Abhishek - avatar
0
Thanks Abhay but I know this method I want to know how to do with while loop
8th Sep 2021, 9:00 AM
Abhishek
Abhishek - avatar