Skip to main content

Posts

Showing posts from May, 2023

What are the characteristics of a good program in C++

The program should be written in a good style so that it is understandable to a reader. A good program is efficient in solving the given program.  Here are some of the characteristics of a good program : Effective and Efficient  User Friendly  Self-Documenting Code  Reliable  Portable  I.  Effective and Efficient The program produces correct results and works faster, taking into account of the memory constraints.  II.  User Friendly The user should not be concerned about inside the program, a program should work with the user by understandable messages and user work should be very low. The user should only be responsible to provide input the rest of the program should do.  III.  Self-Documenting Code A good program must be self-documented. The source code uses meaningful names for variables, subprograms and other constants.  IV.  Reliable The program must be able to handle unexpected situations like wrong data or no data, it should display a proper message or error message when dealin

C++ Program to determine whether an input Year is Leap Year or not

In C++ programming we can write code to check whether a year is a leap year or not. Let's look at the code to input the year and check if it is a leap year or not.  Leap year C++ Program to determine whether an input Year is Leap Year or not #include <stdio.h> int main() {    int year;    printf("Enter a year: ");    scanf("%d", &year);    // leap year if perfectly divisible by 400    if (year % 400 == 0) {       printf("%d is a leap year.", year);    }    // not a leap year if divisible by 100    // but not divisible by 400    else if (year % 100 == 0) {       printf("%d is not a leap year.", year);    }    // leap year if not divisible by 100    // but divisible by 4    else if (year % 4 == 0) {       printf("%d is a leap year.", year);    }    // all other years are not leap years    else {       printf("%d is not a leap year.", year);    }    return 0; }   The output of the Code  C++ Program to determine whet