Leap year calculation in c | How to insert or add an element



#include<stdio.h>
int main(){
    int year;

    printf("Enter any year: ");
    scanf("%d",&year);

    if(((year%4==0)&&(year%100!=0))||(year%400==0))
         printf("%d is a leap year",year);
    else
         printf("%d is not a leap year",year);
  
    return 0;
}

Sample output:
Enter any year: 2010
2010 is not a leap year

Code 2:

#include<stdio.h>
int main(){
    int year;
    int min_year,max_year;

    printf("Enter the lowest year: ");
    scanf("%d",&min_year);

    printf("Enter the heighest year: ");
    scanf("%d",&max_year);

    printf("Leap years in given range are: ");
    for(year = min_year;year <= max_year; year++){
         if(((year%4==0)&&(year%100!=0))||(year%400==0))
             printf("%d ",year);
    }
  
    return 0;
}

How to insert or add an element in the array at specific or desired posting by using c

#include<stdio.h>
int main(){
int a[50],size,num,i,pos,temp;
printf("\nEnter size of the array: ");
scanf("%d",&size);
printf("\nEnter %d elements in to the array: ",size);
for(i=0;iscanf("%d",&a[i]);
printf("\nEnter position and number to insert: ");
scanf("%d %d",&pos,&num);
i=0;
while(i!=pos-1)
i++;
temp=size++;
while(i{
a[temp]=a[temp-1];
temp--;
}
a[i]=num;
for(i=0;iprintf(" %d",a[i]);
return 0;
}


Share on Google Plus

About Unknown

Hello, My name is Mou, I am from Dhaka, Bangladesh and who is trying keep her hand at blogging. I enjoy writing, anything from how to- pieces to endure to just anything at all. My blog will go into detail about all of article. Long time I work with adsense and blogging about 10 years. Doing some SEO work and like that. Please stay close for track down your article for your task and assignment. Feel free to contact with me at moujuena.mou@gmail.com if need. Thanks for visiting.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment