{"id":10864,"date":"2021-09-30T14:30:29","date_gmt":"2021-09-30T09:00:29","guid":{"rendered":"https:\/\/python-programs.com\/?p=10864"},"modified":"2021-11-22T18:34:32","modified_gmt":"2021-11-22T13:04:32","slug":"python-program-to-print-1-and-0-in-alternative-rows","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-1-and-0-in-alternative-rows\/","title":{"rendered":"Python Program to Print 1 and 0 in Alternative Rows"},"content":{"rendered":"

Grab the opportunity to learn all effective java programming language concepts from basic to advance levels by practicing these Java Program Examples with Output<\/a><\/p>\n

Given the number of rows and columns, the task is to print 1 and 0 in alternative rows in C, C++, and Python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given number of rows =4\r\ngiven number of columns=3<\/pre>\n

Output:<\/strong><\/p>\n

1 1 1 \r\n0 0 0 \r\n1 1 1 \r\n0 0 0<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given number of rows =7\r\ngiven number of columns=15<\/pre>\n

Output:<\/strong><\/p>\n

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1<\/pre>\n

Program to Print 1 and 0 in Alternative Rows in C, C++, and Python<\/h2>\n

Below are the ways to print 1 and 0 in alternative rows in C, C++, and Python.<\/p>\n