#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
const int BITS_IN_BYTE = 8;
 
int main(void)
{
    string text = get_string("Text to encrypt!: ");
    int bit;
    int count = 1;
    for (int i = 0, y = 7, n = strlen(text); i < n; i++) {
        int result = text[i];
        while (result != 0 && y >= 0) {
            if (result > (2^y)) {
                bit = 1;
                print_bulb(bit);
                result = text[i] - (2^y);
                y--;
            }
            else {
                bit = 0;
                print_bulb(bit);
                y--;
                }
        printf("\n");
        }
    }
 }
void print_bulb(int bit)
{
    if (bit == 0)
    {
        // Dark emoji
        printf("\U000026AB");
    }
    else if (bit == 1)
    {
        // Light emoji
        printf("\U0001F7E1");
    }
}
I tried this for the cs50 course (https://cs50.harvard.edu/x/2023/psets/2/bulbs/) and Im not sure why it doesnt work correctly. The program's purpose is to get a string from the user and display it in binary using "light bulbs". I looked up now that I was supposed to do it with remainders, but I really want to know what went wrong with this one. I wonder why all bulbs are still "on", either though the value of the array item is supposed to be going down.
 
    