Skip to content

Instantly share code, notes, and snippets.

@TanjinAlam
Created August 18, 2017 00:17
Show Gist options
  • Save TanjinAlam/52e31a309423cf08b152ab96214ce17a to your computer and use it in GitHub Desktop.
Save TanjinAlam/52e31a309423cf08b152ab96214ce17a to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<stdlib.h>
int main ()
{
int i, n, max=0;
int *pData;
scanf("%d",&n);
pData = (int*)calloc(n, sizeof(int));
if(pData==NULL) exit(1);
for (i=0;i<n;i++)
{
scanf("%d",&pData[i]);
if(pData[i]>max)
max = pData[i];
}
printf("The largest element is %d", max);
free(pData);
return 0;
}
@TanjinAlam
Copy link
Author

#include<stdio.h>
#include<string.h>
struct cl
{
int day, month, year;
};

struct cl date;

void input()
{
scanf("%d %d %d", &date.day, &date.month, &date.year);
}
void main()
{
char months[12][10] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
input();

if(date.day<=30)
{
    if(date.month==2 && date.day==29)
    {
        if((date.year%400==0)||(date.year%100!=0 && date.year%4==0))
        {
            printf("%s %d, %d", months[date.month-1], date.day, date.year);
        }
        else
        {
            printf("%d, %d, %d-%d is not leap year", date.day, date.month, date.year, date.year);
        }
    }
    else
        printf("%s %d, %d", months[date.month-1], date.day, date.year);
}
else if(date.day==31 && (date.month==1 || date.month==3 || date.month==5 || date.month==7 || date.month==8 || date.month==10 || date.month==12))
    printf("%s %d, %d", months[date.month-1], date.day, date.year);
else
    printf("%d, %d, %d-%s has only 30 days", date.day, date.month, date.year, months[date.month-1]);

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment