/*WAP to Demonstration of nested loops */
#include<stdio.h>
#include<conio.h>
main( )
{
 int   r, c, sum ;
 for ( r = 1 ; r <= 3 ; r++ )  /* outer loop */
 {
  for ( c = 1 ; c <= 2 ; c++ )  /* inner loop */
  {
   sum = r + c ;
   printf ( "r = %d c = %d sum = %d\n", r, c, sum ) ;
  }
 }
 getch();
}
 
 
No comments:
Post a Comment