Use the Appropriate Variables

This tip submitted by Mahesh Kumar.S on 2005-03-07 21:58:10. It has been viewed 25286 times.
Rating of 5.5 with 52 votes

While programming we have to take care about the variables. You need to give appropriate name for the variables or there will be a lot of confusion!

For instance
int fact(int n)
    int i;
    return n;

int main()
    int no;
    printf("Enter value to fin it's Factorial Value.");
    printf("The Factorial Value is %d",fact(no));
    return 0;

In above program we use name "FACT" for the function to find out it's factorial value. Suppose we gave it a name like
int abc(int n) or
int get(int n)? That wouldn't be so easy to read would it? it might even cause confusion if we chose a name that actually described something we didn't do!

More tips

Help your fellow programmers! Add a tip!