Programming With C : Nested Loops and Jumping Statements- Lecture4

As we discussed in our last chapter

Loops, like if-else statements, can be nested, one within another.

While, the inner and outer loops need not be generated by the same type of control structure.

It is essential,  that one loop be completely embedded within the other  – there can be no overlap.

Therefore, Each loop must be controlled by different index.

Moreover, nested control structure can involve both loops and if-else statement.

Thus, a loop can be nested within an if-else statement, and an if-else statement can be nested within a loop.

Hence, the nested structure may be complex as necessary, as determined by the program logic.

 

#include <stdio.h>

void main()

{ int i,j;

for (i=1; i<=10; i++)

       for(j=1; j<=10; j++)

           printf(“%d  ”, i*j);

Prints 1 2 3 ..10 2 4 6 ..20 ………10 20 30 ……..100

#include <stdio.h>

void main()

{ int i=1,j=1;

while(i<=10)

   { while(j<=10)

        { printf(“  %d”, i*j);

            j++;}

     i++;} }

Jumping Statements

Whereas jumping statements are also known as Loop Control Statements.

These statements are of different types

  • break
  • continue
  • goto
  • return, and
  • exit ()

 

Programming With C : Lecture 1

Programming With C : Lecture 2

C : Lecture 3

 

Published by

Gagan Deep

FOUNDER & DIRECTOR, ROZY COMPUTECH SERVICES, KUK, KURUKSHETRA (HARYANA), INDIA I am in the profession of teaching in Computer Science since 1996.  In 1996, established a professional setup “Rozy Computech Services” for providing Computer Education, computer hardware and software services. In this span of 21 years , in conjunction with Rozy’s, I also associated in Teaching with different Institutions like Assistant Professor in University College, Kurukshetra University, Kurukshetra, Guest Faculty in Directorate of Distance Education, Kurukshetra University, Visiting Faculty in University Institute of Engineering & Technology, Kurukshetra University and a Resource person in EDUSAT, Haryana. Besides, I am also serving as Guide and Mentor in various private educational institutions. Also written 7 books on computer science.

4 thoughts on “Programming With C : Nested Loops and Jumping Statements- Lecture4

  1. My spouse and I stumbled over here coming from a different page and thought
    I may as well check things out. I like what I
    see so i am just following you. Look forward to going over your web page repeatedly.

  2. Hello there, just became aware of your blog through Google, and found that it’s truly informative.
    I am going to watch out for brussels. I will be grateful if you continue this in future.

    Lots of people will be benefited from your writing. Cheers!

  3. Hello there,

    My name is Aly and I would like to know if you would have any interest to have your website here at rozyph.com promoted as a resource on our blog alychidesign.com ?

    We are in the midst of updating our broken link resources to include current and up to date resources for our readers. Our resource links are manually approved allowing us to mark a link as a do-follow link as well
    .
    If you may be interested please in being included as a resource on our blog, please let me know.

    Thanks,
    Aly

Leave a Reply

Your email address will not be published. Required fields are marked *