In: Computer Science
REWRITE THE FOLLOWING CODES USING FOR LOOP. PLS USE C LANGUAGE FORMAT
#include <stdio.h>
int main(void) {
int count ;
scanf("%d",&count);
while(count--){
printf("\--------------------------------------------\ \n");
printf("\ BBBBB A \ \n");
printf("\ B B A A \ \n");
printf("\ BBBB A A \ \n");
printf("\ B B AAAAAAA \ \n");
printf("\ BBBBB A A \ \n");
printf("\---------------------------------------------\ \n");
}
return 0;
}
#include <stdio.h>
int main(void)
{
int count,i;
scanf("%d",&count);
for(i=count;i>0;i--)//here we use
for loop to do the same work
{
printf("\\--------------------------------------------\\ \n");//We need to use one extra \ before \ (\\) to print \ on output screen just like \n gives new line
printf("\\
BBBBB
A
\\ \n");
printf("\\ B B A A \\ \n");
printf("\\
BBBB
A
A
\\ \n");
printf("\\
B
B
AAAAAAA
\\ \n");
printf("\\
BBBBB
A
A
\\ \n");
printf("\\---------------------------------------------\\ \n");
}
}