UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is the benefit of using #define to declare a constant?

Asked by Last Modified  

4 Answers

Learn C Language

Follow 0
Answer

Please enter your answer

Computer & Maths Professor

Consider a scenario where we are using a C program to generate marksheets of students. The maximum marks per subject are 100 and we are using 100 in let us say 5 formulas in the entire program. Now, if the maximum marks changes from 100 to 70, we need to make changes at 5 places if we use 100 directly....
read more
Consider a scenario where we are using a C program to generate marksheets of students. The maximum marks per subject are 100 and we are using 100 in let us say 5 formulas in the entire program. Now, if the maximum marks changes from 100 to 70, we need to make changes at 5 places if we use 100 directly. On the other hand, if we had used MAX constant with the help of # define, we need to change at only 1 place. read less
Comments

Doing mathematics & computing from IIT Delhi

It becomes a global variable. You can use it main and in any function in the file.
Comments

Using the #define method of declaring a constant enables you to declare a constant in one place and use it throughout your program. This helps make your programs more maintainable, because you need to maintain only the #define statement and not several instances of individual constants throughout your...
read more
Using the #define method of declaring a constant enables you to declare a constant in one place and use it throughout your program. This helps make your programs more maintainable, because you need to maintain only the #define statement and not several instances of individual constants throughout your program. For instance, if your program used the value of pi (approximately 3.14159) several times, you might want to declare a constant for pi as follows: #define PI 3.14159 This way, if you wanted to expand the precision of pi for more accuracy, you could change it in one place rather than several places. Usually, it is best to put #define statements in an include file so that several modules can use the same constant value. read less
Comments

Thanks for the question Govind ...... The constant which have defined using #define function can be used anywhere in the program without re declaration Thanks, Team DishaaPro www.dishaapro.com
Comments

View 2 more Answers

Related Questions

What is the best website to learn c language?
First go through the book "Let Us C" by Yashawant Kanetkar, then try to implement few small codes by your own, it takes time but you will learn it properly by experience only
Nom
What is the benefit of using enum to declare a constant?
ENUMS.. Can give numerical values for Sunday, Monday,... Easy to use in coding... Makes the program more readable/ understandable, than using 1,2,3.. Etc.
Sita
0 0
7
How do I become good in competitive programming in a year if I have just started learning C language?
The best topics to learn would be Data structures and also the analysis of algorithms..(THESE ARE BASICS BUT IF U LEARN THEM PROPERLY!!! CODING WOULD BE A PIECE OF CAKE FOR U....)
Anmol
0 0
9
how to calculate address of n dimensional matrix
An n dimensional matrix can be of any dimension. Adding a dimension is adding one more index number (to access the element). In 1-D array you the elements are linearly arranged and can be addressed as...
Rupendra
How do I start learning C programming and finish it in one month?
Please follow the book "C Programming" by Detal & Detal. Its an applied book easy to understand compare to others. U may also learn through online free tutorial.
Pallavi
0 0
8

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Recommended Articles

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more