Question

In: Computer Science

REWRITE FOLLOWING CODES USING DO...WHILE LOOP. BY USING C LANGUAGE #include <stdio.h> int main(void) {     ...

REWRITE FOLLOWING CODES USING DO...WHILE LOOP. BY USING C LANGUAGE

#include <stdio.h>

int main(void) {

     int count =2;

// COUNT TAKEN 2 AS TO PRINT 2 TIMES          

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;

}

Solutions

Expert Solution

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

Brother below is the code in which do while loop is used instead of normal while. Brother the spaces might be changed/ So, I request you to go through below link where I have saved the code.

https://onlinegdb.com/B1gDBXWSLB

#include <stdio.h>

int main(void) {

int count =2;

// COUNT TAKEN 2 AS TO PRINT 2 TIMES

do{

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");
count--;
}while(count>=1);

return 0;

}

Kindly revert for any queries

Thanks.


Related Solutions

REWRITE THE FOLLOWING CODES USING FOR LOOP. PLS USE C LANGUAGE FORMAT #include <stdio.h> int main(void)...
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; }
What is the output of the following C program? #include<stdio.h> int fac (int x); void main(...
What is the output of the following C program? #include<stdio.h> int fac (int x); void main( ) {                         for (int i=1; i<=2; i++)                                     printf("%d", fac(i)); } int fac(int x) {                         x = (x>1) ? x + fac(x-1) : 100);                         return x; }
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x...
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x = 3;     i = fun(x);     printf("%d\n", i);     return 0; } int fun(int i) {      int res = 0;      res = pow (i , 3.0);      return ( res); }
//using c fixing the error to make a correct print-out. #include <stdio.h> int main(void) { unsigned...
//using c fixing the error to make a correct print-out. #include <stdio.h> int main(void) { unsigned int a = 1000; signed int b = -1; if (a > b) printf("%d is more than ", a); printf("%d\n", b); else printf("%d is less or equal than ", a); printf("%d\n", b); return 0; }
Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number;...
Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number; Scanf (“%d”, & number); if (number % 2 ==0) { printf (“Even\n”); } else { printf(“Odd\n”); } Return 0; }
example_thread.c #include <stdio.h> #include <stdlib.h> #include <pthread.h> int shared= 0; void race(void); int main(){     pthread_t...
example_thread.c #include <stdio.h> #include <stdlib.h> #include <pthread.h> int shared= 0; void race(void); int main(){     pthread_t player1, player2, player3;     pthread_create(&player1, NULL, (void *)race, NULL);     pthread_create(&player2, NULL, (void *)race, NULL);     pthread_create(&player3, NULL, (void *)race, NULL);     pthread_join(player1, NULL);     pthread_join(player2, NULL);     pthread_join(player3, NULL);     printf("Total Number = %d\n", shared);     return 0; } void race(void) {     long i,tmp;     for(i=1; i<=200000; i++) {         tmp = shared;         tmp = tmp + 1;         shared =...
Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main(){ int numItms, j,...
Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main(){ int numItms, j, data, sum; scanf("%d",&numItms); sum = 0; for(j = 1; j <= numItms; j++){ scanf("%d",&data); sum += data; } printf("Sum:%d\n",sum); return 0; } SAMPLE INPUT: 48-376 SAMPLE OUTPUT: Sum: 18
#include <stdio.h> int main(void) { int input = -1; double average = 0.0;    /* Use...
#include <stdio.h> int main(void) { int input = -1; double average = 0.0;    /* Use this for your input */ scanf("%d", &input);    /* This is the only output you need */ printf("%.1lf", average); return 0; } Please write a C coding program (make it simple coding)  that find the average of sequence integer. when user enter integers, once at a time. Also, If the user enters 0 (zero), the code will calculates the average and then prints it, and...
#include <stdio.h> #include <stdlib.h> #include <time.h> void sort(int a[], int size); void printArray(int a[], int size);...
#include <stdio.h> #include <stdlib.h> #include <time.h> void sort(int a[], int size); void printArray(int a[], int size); int main(){ int arraySize, limit, count, srand(time(0)); print f("Enter the size of array\n"); scanf("%d", arraySize); int array[arraySize]; printf("Enter the upper limit\n"); scanf("%d", &limit); count = 0; while(count <= arraySize){ array[count] = (rand() % (limit + 1)); count++; } printArray(array, &arraySize); sort(array, arraySize); printArray(array, arraySize); Return 0; } void printArray(int a[], int size){ int i = 0; printf("Array: ["); while(i < size){ if(i != size...
#include <stdio.h> const int DECK_SIZE = 52; int deck[DECK_SIZE]; int main(void) { /* Populate the deck...
#include <stdio.h> const int DECK_SIZE = 52; int deck[DECK_SIZE]; int main(void) { /* Populate the deck */ for(int i = 0; i < DECK_SIZE; i++) { deck[i] = i + 1; }    /* Get the cut position as an integer input */    /* Verify that the input is valid */    /* Cut the deck */    /* Print the resulting deck with one element on each line */ return 0; } Write a program that "cuts" a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT