Program to create a loading bar effect using C programming language

#include<stdio.h>
#include<unistd.h>
int main()
{
    const int totalspace = 100;
    const int barWidth = 20;
    for(int count = 0; count <= totalspace; count++)
    {
        float progress = (float)count / 100;
        float progressBar = progress * barWidth;
        printf("[");
        for(int i = 0; i < barWidth; i++)
        {
            if(i < progressBar)
            {
                printf("#");
            }

            else
            {
                printf(" ");
            }

        }
        usleep(10000);

        printf("] %.2f%%\r", progress * 100);
    }
    return 0;
}

Comments

Popular posts from this blog

AI and Human Evolution

Snake Game using JAVA

To Do List App (GUI) using C#