June 2, 2023
Program to use comma operator in for loop C Language
#include<stdio.h>
int main(void)
{
int i,j;
for(i=0,j=10;i<=j;i++,j--)
{
printf("i=%d\t j=%d\n",i,j);
}
return 0;
}
output
i=0 j=10
i=1 j=9
i=2 j=8
i=3 j=7
i=4 j=6
i=5 j=5
by : Nadeem Khan
Quick Summary:
Program to use comma operator in for loop C Language copy #include<stdio.h> int main(void) { int i,j; for(i=0,j=10;i<=j;i++,j–) { printf(“i=%d\t j=%d\n”,i,j); } return 0; } output i=0 j=10 i=1 j=9 i=2 j=8 i=3 j=7 i=4 j=6 i=5 j=5