Saturday, November 12, 2016

C program to print Software Installation Bar.

#include<stdio.h>
#include<Windows.h>

//setxy function sets the cursor coordinate X, Y
COORD c = {0, 0};
void setxy (int x, int y){
 c.X = x; c.Y = y; // Set X and Y coordinates
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}

int main(){
    int i;
    printf("\n Installing Software ....\n");
    for(i=0; i<=100; i++)
    {
        setxy(i,2);
        printf("%c ", 219);
    
        setxy(0,3);
        printf("%d %%", i);
    
        Sleep(100);
    }
    printf("\n\n Software Successfully Installed...");
    getch();
    return 0;
}


Output of the program:

You will see Installation bar progressing from 0 % to 100% as shown below:




No comments:

Post a Comment