Posts

Showing posts from September, 2019

Two Matrix Spiral Print

The program must accept two square matrices which are of size  N*N . Then the values in the matrices must be printed spirally in clock wise direction in a single line. The values in a specific row or column of the first matrix must follow the values in the same row or column of the second matrix. Boundary Condition(s): 1 <= N <= 30 1 <= Integer value in the matrix <= 1000 Input Format: The first line contains N. Next 2N lines contain N values each (First N lines contain the values in the first matrix and the next N lines contain the values in the second matrix). Output Format: The first line contains 2*N*N values in the two matrices printed spirally. Example Input/Output 1: Input: 5 10 20 30 40 50 60 70 80 90 91 88 86 34 35 36 21 22 23 24 25 71 72 73 74 75 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 Output: 10 20 30 40 50 101 102 103 104 105 91 36 25 75 110 115 120 125 74 73 72 71 124 123 122 121 21 88 60 1

Swap - Multiples of X and Y

The program must accept  N  integers and two integers  X  and  Y  as the input. The program must swap the first occurring mutiple of X and the last occurring multiple of Y among the N integers. Then the program must print modified values of the N integers as the output. Note : At least one multiple of X and Y are always present in the N integers. Boundary Condition(s): 2 <= N <= 100 1 <= X, Y <= 100 1 <= Each integer value <= 10^8 Input Format: The first line contains the value of N. The second line contains the value of N integers seperated by space(s). The third line contains the value of X and Y seperated by space(s). Output Format: The first line contains the modified value of N integers as per the conditions. Example Input/Output 1: Input: 10 13 28 76 34 86 77 18 92 57 10 7 11 Output: 13 77 76 34 86 28 18 92 57 10 Explanation: The first occurring multiple of 7 among the 10 integers is 28. The last occurring multiple of 11 among the 10 integers is 77

Consonants in Range

The program must accept two lower case alphabets  CH1  and  CH2  as the input. The program must print all the consonants from CH1 to CH2 as the output. Input Format: The first line contains CH1 and CH2 separated by a space. Output Format: The first line contains all the consonants from CH1 to CH2. Example Input/Output 1: Input: a z Output: b c d f g h j k l m n p q r s t v w x y z Explanation: All the consonants (except the vowels) from  a  to  z  are printed as the output. Example Input/Output 2: Input: v h Output: v t s r q p n m l k j h Solution:- #include<stdio.h> #include <stdlib.h> int isvowel(char ch) {     if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')     return 1;     else     return 0; } int main() {     char ch1,ch2;     scanf("%c %c",&ch1,&ch2);       if(ch1<ch2)     {         while(ch1<=ch2)         {             if(!isvowel(ch1))