Answers for "how to create a nested for loop in c"

C
0

how to create a nested for loop in c

//Nested for loop in C
int main()
{
   for (int i=0; i<2; i++)
   {
	for (int j=0; j<4; j++)
	{
	   printf("%d, %d\n",i ,j);
	}
   }
   return 0;
}
//Alternative approach to nested for loop
int main()

{
    int i,j;
   for (i=1,j=1 ; i<10 || j<10; i++,j++)
   {
	printf("%d, %d\n",i ,j);
   }
   return 0;

}
Posted by: Guest on September-30-2020

Code answers related to "C"

Browse Popular Code Answers by Language