When we were in first year, we were taught the programming language/syntax named 'C'. We used the Dev-C++ IDE to construct, compile and run our little creations.
For this entry I would be sharing some examples of the IF and ELSE arguments.
I hope these codes would help any student or aspiring programmer. I believe that C is the most basic of all programming languages - you can't learn other languages unless you understand the logic and flow of C.
// leap year/common year indicator
#include <stdio.h>
int main()
{
int leapyear, year;
printf("Input your desired year : \n");
scanf("%d",&year);
if ((year%100)==0)
leapyear=((year%4)==0);
else
leapyear=((year%4)==0);
if(leapyear)
printf("%d is a leap year\n",year);
else
printf("%d is a common year\n",year);
getche ();
}
Saturday, September 5, 2009
Subscribe to:
Post Comments (Atom)



0 comments:
Post a Comment