diff --git a/Q41_Snake_pattern.cpp b/Q41_Snake_pattern.cpp new file mode 100644 index 0000000..99ba984 --- /dev/null +++ b/Q41_Snake_pattern.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; +// Print matrix in snake pattern +int main() +{ + int n,m,i,j; + cout<<"Enter the count of row and column matrix: "; + cin>>m>>n; + int arr[m][n]; + for(i=0;i>arr[i][j]; + } + } + cout<<"Snake pattern: "; + for(i=0;i=0;j--) //If row is odd then print it in reverse format. + cout<<" "< +using namespace std; + +// Program to convert decimal to binary +void dectobin(int n) +{ + // array to store binary number + int binaryNum[64]; + // counter for binary array + int i = 0; + while (n > 0) + { + // storing remainder in binary array + binaryNum[i] = n % 2; + n = n / 2; + i++; + } + // printing binary array in reverse order + for (int j = i - 1; j >= 0; j--) + cout << binaryNum[j]; +} +int main() +{ + int n; + cout<<"Enter the Decimal value: "; + cin>>n; + cout<<"Binary value : "; + dectobin(n); +}