Question-Write a program to generate all combinations of 1, 2 and 3 using for loop.
Solution-
That's how it goes.
#include<stdio.h>
int main()
{
int i,j,k;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
for(k=1;k<=3;k++)
printf("%d%d%d ",&i,&j,&k);
}
}
return 0;
}
Solution-
That's how it goes.
#include<stdio.h>
int main()
{
int i,j,k;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
for(k=1;k<=3;k++)
printf("%d%d%d ",&i,&j,&k);
}
}
return 0;
}
first thing the questions ask of combinatio involving all three at once and even if it doesn't you code is passing the address of i, j, k, in the printf statement. correct it up!
ReplyDelete