#include <iostream> using namespace std; int main() { int year; cout << "Enter a year: "; cin >> year; if (year % 4 == 0) { if (year % 100 == 0) { if (year % 400 == 0) cout << year << " is a leap year."; else cout << year << " is not a leap year."; } else cout << year << " is a leap year."; } else cout << year << " is not a leap year."; return 0; } Output
Enter a year: 2014
2014 is not a leap year. 2) Write a C++ Program armstrong between two numbers #include <iostream> #include <cmath> using namespace std; int main() { int lowerbound, upperbound, digitSum, temp, remainderNum, digitNum ; lowerbound = 100; upperbound = 500; cout<<"Armstrong Numbers between "<<lowerbound<<" and "<<upperbound<<" are: "; for(int num = lowerbound; num <= upperbound; num++) { temp = num; digitNum = 0; while (temp != 0) { digitNum++; temp = temp/10; } temp = num; digitSum = 0; while (temp != 0) { remainderNum = temp%10; digitSum = digitSum + pow(remainderNum, digitNum); temp = temp/10; if (num == digitSum) cout<<num<<" "; } return 0; } Output Armstrong Numbers between 100 and 500 are: 153 370 371 407