answersLogoWhite

0


Best Answer

there are various types of naming rule provide for function ,identifier,i.e variables.but naming rule for variable must meet certain condition..

1.you can easily idenfy what is variable for.for eg.you may use

int a;/to store no of student in your prog. but it is better instead of using "a",you can write any of the following definition

int stu; or int stu_no; or int studentno;

2.it must be abbreviated.because although modern compiler support 32 char variable but still where you use that variable you have to type that name again &again.

so for eg. in the above case int stu_no; is optimal.

when these precondition are met then here are some rules for naming a variable:

1.you use only English alphabet,numeric no,& _(underscore).

2.you must start with a alphabet. then you continue with alphabet or numeric or under score.for eg. you can define a variable like

int stu_comp_2009;//for no of student 2009 batch.

3.no variable can start with number or _.such naming may cause some compiler do the right job but maximum would not support this.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

A variable in C starts with an alpha character, followed by any number of characters which are alpha, numeric, or underscores, and may not be a word that is part of the C syntax.

For instance, you can name a variable "What", "are", "the" "rules", but you can't name it "for", nor "4square" nor "a+" nor "bobble-head".

Traditionally, c programmers have adopted i,j,k,l,m,n as names of indexes. While traditionally, programmers have used lowercase for variables and UPPERCASE for constants, programmers at Microsoft started using "Hungarian notation" in the late 1980s, which encodes the type of variable into a camel-cased variable name, and this practice has been adopted by many.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

1. What are the rules used in naming variable? Give examples.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

Rules used in naming variable Give examples

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

What r the rules used in naming variable?Give examples.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Rules in naming variables in programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are variables in programming?

In computer programming, variables refer to a particular location in the memory that holds a value. Variables are equivalent to their assigned values.


Is internet programming really different from other programming paradigms?

By definition, each "programming paradigm" is different from every other one, but they all share some common features and attributes. Most have at least a lexicon, syntax rules, and variables.


What are the rules for naming new elements?

The IUPAC rules for naming new chemical elements are at this link.


What is a coding manual?

Coding manuals, also known as programming standards manuals, are used to define the standards associated with programming in a particular environment. A coding manual will provide standards for: * Variable Naming * Subroutine/Function Naming * Comments * Nesting (e.g., how to reflect loops, if statements, etc.) * Structure (e.g., where global variables are defined, etc.) * Code Reviews and other standards that might be specific to a particular programming environment.


What is the prefix for variable?

In programming, the term "prefix" typically refers to a naming convention that precedes the name of a variable. Common prefixes include "int" for integer variables, "str" for string variables, "bool" for boolean variables, and so on. These prefixes help developers quickly identify the data type of a variable.


What are the naming rules on Microsoft Word 2007?

Upper & Lower case letters are the naming rules on Microsoft Word 2007.


What type of linear programming can be found by graphical methods?

A linear programming question with two variables. Problems with three can be solved if there is a constraint that reduces them to effectively two variables. Linear programming with 3 variables, using 3-d graphs is possible but not recommended.


What are the naming rules in XML?

XML has no rules like html in regards to tags and naming tags, you write your own xml tags.


Why we use underscore in cpp language?

Underscores are often used in C++ to separate words in variable names for readability, known as snake_case. It's a common naming convention in C++ and many other programming languages. Additionally, underscores are used to indicate private member variables in classes to differentiate them from public variables.


How are constants and variables important in devoloping java programs?

Without variables, you won't be able to do much programming. Variables is where you store data; such data may change over time. And computer programming is all about manipulating data.


What are naming rules for Microsoft office word?

ribbons


What does the acronym JNDI stand for?

The acronym 'JNDI' stands for Java Naming and Directory Interface. What this refers to is the naming system for Java, a computer programming language.