Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(){
- int rows, columns;
- printf("Enter the rows and columns: ");
- scanf("%d %d", &rows, &columns);
- if((rows%2 == 0) || (columns%2 == 0)){
- printf("invalid");}
- else{
- for(int j=1; j<=(rows/2); j++){
- for(int i=1; i<=(columns/2); i++){
- printf("1");
- }
- printf("0");
- for(int i=1; i<=(columns/2); i++){
- printf("1");
- }
- printf("\n");
- }
- for(int i=1; i<=(columns); i++){
- printf("0");
- }
- printf("\n");
- for(int j=1; j<=(rows/2); j++){
- for(int i=1; i<=(columns/2); i++){
- printf("1");
- }
- printf("0");
- for(int i=1; i<=(columns/2); i++){
- printf("1");
- }
- printf("\n");
- }
- }
- return 0;
- }
- /*OUTPUT:
- Enter the rows and columns: 5 5
- 11011
- 11011
- 00000
- 11011
- 11011
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement