-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
532f137
commit 003e5a8
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
#include <stdio.h> | ||
|
||
char *month_name(int m) | ||
{ | ||
char *months[] = { | ||
"January", "February", "March", "April", "May", "June", "July", "August", | ||
"September", "October", "November", "December"}; | ||
|
||
return months[m - 1]; | ||
} | ||
|
||
int main() | ||
{ | ||
int m; | ||
|
||
printf("Enter month number: "); | ||
scanf("%d", &m); | ||
|
||
printf("Month name: %s\n", month_name(m)); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <stdio.h> | ||
|
||
int leap(int year) | ||
{ | ||
if (year % 400 == 0) | ||
return 1; | ||
else if (year % 100 == 0) | ||
return 0; | ||
else if (year % 4 == 0) | ||
return 1; | ||
else | ||
return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
int year; | ||
|
||
printf("Enter year: "); | ||
scanf("%d", &year); | ||
|
||
if (leap(year)) | ||
printf("%d is a leap year.\n", year); | ||
else | ||
printf("%d is not a leap year.\n", year); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
double round2(double x) | ||
{ | ||
return round(x * 100) / 100; | ||
} | ||
|
||
int main() | ||
{ | ||
double x; | ||
|
||
printf("Enter a floating point value: "); | ||
scanf("%lf", &x); | ||
|
||
printf("Rounded value: %.2lf\n", round2(x)); | ||
|
||
return 0; | ||
} |