how can i convert binary number to decimal using forloop
First of all, all numbers on the computer are represented in binary, normally. You have to tell the compiler what format you want to show numbers.
I also expect this is a homework problem. But I want to help you.
So I will frame the question so I can answer it. Represent an integer in a binary representation using an array of integers. You can modify this program to use an array of characters if you want and then convert each integer (1 or 0) to a character (1 or 0) in the for loop:
int D = 111 ;
int B [ 8 ] ;
for ( int i = 0 ; i < 8 ; ++ i )
B [ 7 - i ] = D % 2 ;
D /= 2 ;