+ 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
10 odpowiedzi
+ 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
+ 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
+ 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;
}
+ 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
+ 1
Thank you @Saurabh Kumar Yadav
I got it
+ 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....
0
Because teacher has said to do with while loop that's why
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;
}
0
I can't know how to proceed
0
Thanks Abhay but I know this method
I want to know how to do with while loop