Posts

Showing posts from August, 2020

WAP to find leap year in c language

 #include<stdio.h> int main()  { int year; for(year=1900;year<=2400;year++)       {            if(year%400==0||(year%100!=0&&year%4==0))           printf("%d\n",year);        } return 0; }

Swapping two numbers using three different methods

 First method- (using three variables)  #include<stdio.h> int main()  { int a=10,b=20,c; c=a; a=b; b=c; printf("%d %d",a,b); return 0; } Second method-(using two variables)  #include<stdio.h> int main()  { int a=10,b=20; a=a+b; b=a-b; a=a-b; printf("%d %d",a,b); return 0; } Third method-(using two variables in single line)  #include<stdio.h> int main()  { int a=10,b=20; b=a+b-(a=b) ; printf("%d %d",a,b); return 0; }