From 04c30ca2c7c0253b87bee7e714ab94b1914b2436 Mon Sep 17 00:00:00 2001 From: Chamudi Rasanjalee <91789995+chamz99@users.noreply.github.com> Date: Thu, 7 Oct 2021 11:17:53 +0530 Subject: [PATCH 1/2] change the year check --- helloworld.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/helloworld.c b/helloworld.c index e13dbd0..be8760c 100644 --- a/helloworld.c +++ b/helloworld.c @@ -1,7 +1,26 @@ #include - +#include +int leapYear(int); int main() { - printf("HAPPY NEW YEAR"); + printf("happy new year\n"); + printf("----Lest check this year is leap year or not-------\n"); + int year; + printf("Enter the year : \n"); + scanf("%d",&year); + + if(leapYear(year)) + printf("%d is a leap year",year); + else + printf("%d is not a leap year",year); + getch(); return 0; -} \ No newline at end of file +} +int leapYear(int x) +{ + if((x%400==0)||((x%4==0)&&(x%100!=0))) + + return 1; + else + return 0; +} From 29d41c9bbb6f623ae0b8a2ffc7d17b5b2dceb777 Mon Sep 17 00:00:00 2001 From: Chamudi Rasanjalee <91789995+chamz99@users.noreply.github.com> Date: Thu, 7 Oct 2021 23:40:21 +0530 Subject: [PATCH 2/2] improve the c++ code --- CPP Programs/printno.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/CPP Programs/printno.cpp b/CPP Programs/printno.cpp index 399420b..6bed17d 100644 --- a/CPP Programs/printno.cpp +++ b/CPP Programs/printno.cpp @@ -2,11 +2,24 @@ using namespace std; int main() { - int number; + int number,i,m=0,flag=0; - cout << "Enter an integer: "; + cout << "Enter an integer: "; cin >> number; - cout << "You entered " << number; + cout << "You entered " << number; + + m=number/2; + for(i = 2; i <= m; i++) + { + if(number % i == 0) + { + cout<<" ,Number is not Prime."<