Predict the Output: int x = 1;switch(x) { case 1: …
Predict the Output: int x = 1;switch(x) { case 1: printf(“A”); case 2: printf(“B”); break; default: printf(“C”);} Explain what is printed and why? Consider the code is fully formed, i.e., no excuses like missing main(), missing stdio.h, etc.
Read DetailsGiven two strings st1[], and st2[], implement a logic to com…
Given two strings st1[], and st2[], implement a logic to compare the two strings, without using the string.h library and it’s functions. Concentrate on your array logic, variables, and printf() statements. Assume both the strings are already declared and defined, and the size of input string is unknown. Sample output: For example, if st1[] = “Hello, How are you.” and st2[] = “Welcome to UTSA…” The strings are unequal. Note: Using library string functions will give NO points.
Read DetailsWrite a logic that prints the following pattern (right-half…
Write a logic that prints the following pattern (right-half diamond), based on the input value for N. Concentrate on your loop logic, variables, and printf() statements. Hint: Each line has some spaces, and some *s; and each element is of width 3. For example, for N = 5: Row 1: Element-1, and element-2 are spaces (each of width 3, i.e., 3 spaces). Element-3 is a * (of width 3, i.e., a space, a *, and a space). Row 2: Element-1 and 2 are spaces, Element-3, Element-4 are *. Row 3: Element-1 and 2 are spaces, 3, 4, and 5 are *s. Row 4: Repeat Row-2 logic. Row 5: Repeat Row-1 logic. Once you come up with a formula, the implementation should be a cakewalk. If N = 3, it should print * * * * If N = 5, it should print * * * * * * * * *
Read DetailsGiven two matrices (2-D array) of elements, implement a logi…
Given two matrices (2-D array) of elements, implement a logic to print the sum of the matrix. Concentrate on your array logic, variables, and printf() statements. Assume the array is already declared and defined, and is of size SIZExSIZE. int array[][] = {{row of elements}, {row of elements}, … , {row of elements}}; Sample output: For example if array1[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; array2[][] = {{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}; The sum of the matrix is: 10 10 10 10 10 10 10 10 10
Read DetailsWrite a logic that prints the following pattern (a diamond),…
Write a logic that prints the following pattern (a diamond), based on the input value for N. Concentrate on your loop logic, variables, and printf() statements. Hint: Each line has some spaces, and some *s; and each element is of width 3. For example, for N = 5: Row 1: Element-1, and element-2 are spaces (each of width 3, i.e., 3 spaces). Element-3 is a * (of width 3, i.e., a space, a *, and a space). Row 2: Element-1 is space, Element-2, Element-3, Element-4 are *. Row 3: Element-1, 2, 3, 4, and 5 are *s. Row 4: Repeat Row-2 logic. Row 5: Repeat Row-1 logic. Once you come up with a formula, the implementation should be a cakewalk. If N = 3, it should print * * * * * If N = 5, it should print * * * * * * * * * * * * *
Read DetailsGiven a matrix (2-D array) of elements, implement a logic to…
Given a matrix (2-D array) of elements, implement a logic to print the transpose of the matrix. Concentrate on your array logic, variables, and printf() statements. Assume the array is already declared and defined, and is of size SIZExSIZE. int array[][] = {{row of elements}, {row of elements}, … , {row of elements}}; Sample output: For example if array[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; The transpose of the matrix is: 1 4 7 2 5 8 3 6 9
Read Details