UrbanPro

Learn C Language from the Best Tutors

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

Search in

How can you tell if a loop ended prematurely?

Asked by Last Modified  

4 Answers

Learn C Language

Follow 1
Answer

Please enter your answer

Professional Tutor with 15 years of experience.

If we check the loop variable we can check whether the loop is terminated or completed.
Comments

Computer Wizard

Generally, loops are dependent on one or more variables. Your program can check those variables outside the loop to ensure that the loop executed properly. For instance, consider the following example: #define REQUESTED_BLOCKS 512 int x; char* cp; /* Attempt (in vain, I must add...) to allocate...
read more
Generally, loops are dependent on one or more variables. Your program can check those variables outside the loop to ensure that the loop executed properly. For instance, consider the following example: #define REQUESTED_BLOCKS 512 int x; char* cp[REQUESTED_BLOCKS]; /* Attempt (in vain, I must add...) to allocate 512 10KB blocks in memory. */ for (x=0; x< REQUESTED_BLOCKS; x++) { cp[x] = (char*) malloc(10000, 1); if (cp[x] == (char*) NULL) break; } /* If x is less than REQUESTED_BLOCKS, the loop has ended prematurely. */ if (x < REQUESTED_BLOCKS) printf(“Bummer! My loop ended prematurely!\n”); Notice that for the loop to execute successfully, it would have had to iterate through 512 times. Immediately following the loop, this condition is tested to see whether the loop ended prematurely. If the variable x is anything less than 512, some error has occurred. read less
Comments

Computer & Maths Professor

Generally, loops are dependent on one or more variables. Your program can check those variables outside the loop to ensure that the loop executed properly. For example, if a loop is executed with the help of i variable 10 times, the value of i if less than 10 (outside the loop) indicates premature end...
read more
Generally, loops are dependent on one or more variables. Your program can check those variables outside the loop to ensure that the loop executed properly. For example, if a loop is executed with the help of i variable 10 times, the value of i if less than 10 (outside the loop) indicates premature end of loop read less
Comments

Tutor

Generally, loops are dependent on one or more variables. Your program can check those variables outside the loop to ensure that the loop executed properly. when the last condition is executed and when the test expression fails the loop will end and the program control goes out from the loop.
Comments

View 2 more Answers

Related Questions

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
What are the types of linkages in C Programming?
EXTERNAL,INTERNAL,NONE are 3 types of linkage in C programming
Akash
0 0
9
How do I write a C program to print the total number of a single-digit prime number using a loop?
total number of single digit prime number that means your prime number starts from 2 and less than 9 so you can take loop for this range
Momin
0 0
7
How do I send a C program via email?
By using Google drive
Furqankhan
0 0
5
how much time does it take to learn c language from basic to advance range
3 month and also depend in your skill to learning power...
Nithin

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 >

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

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