What will be the output for the following code?
#include <stdio.h>
#include <math.h>
void PowerSet(char *set, int set_size)
{
unsigned int pow_size = pow(2, set_size);
int count, j;
for(count = 0; count < pow_size; count++)
{
for(j = 0; j < set_size; j++)
{
if(count & (1<<j))
printf("%c", set[j]);
}
printf(",");
}
}
int main()
{
char strset[] = {'a','b','c'};
PowerSet(strset, 3);
return 0;
}
#include <stdio.h>
#include <math.h>
void PowerSet(char *set, int set_size)
{
unsigned int pow_size = pow(2, set_size);
int count, j;
for(count = 0; count < pow_size; count++)
{
for(j = 0; j < set_size; j++)
{
if(count & (1<<j))
printf("%c", set[j]);
}
printf(",");
}
}
int main()
{
char strset[] = {'a','b','c'};
PowerSet(strset, 3);
return 0;
}
A. a,b,ab,c,ac,bc,abc,
B. a,b,ab,c,ac,bc,abc
C. ,a,b,ab,c,ac,bc,abc,
D. ,abc,bc,ac,c,ab,b,a,
Answer: Option C
Join The Discussion