Sunday, September 4, 2016

// // Leave a Comment

C Checkerboard Pattern Of Asterisks

Question: Display the following checkerboard pattern with eight printf statements and then display the same pattern with as few printf statements as possible.
Checkerboard pattern of asterisks
/* 
 * Author: AGHATISE OSAZUWA
 * Website: www.cscprogrammingtutorials.com 
 *
 * Program to display checkerboard pattern of asterisks.
 */

#include <stdio.h>
int main ( ){ 
    //using eight printf statements
    printf("* * * * * * * *\n");
    printf(" * * * * * * * *\n");
    printf("* * * * * * * *\n");
    printf(" * * * * * * * *\n");
    printf("* * * * * * * *\n");
    printf(" * * * * * * * *\n");
    printf("* * * * * * * *\n");
    printf(" * * * * * * * *\n\n\n");
    
    //using as few printf statements as possible
    printf("* * * * * * * *\n * * * * * * * *\n* * * * * * * *\n * * * * * * * *\n");
    printf("* * * * * * * *\n * * * * * * * *\n* * * * * * * *\n * * * * * * * *\n");
    return 0;
}
Click here to see other solutions to Deitel C How To Program exercises. You can also click here to see the same program in Java.

0 comments:

Post a Comment


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately.

Thanks.