GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

What does the following code print out? int x; printf( “%d”,…

What does the following code print out? int x; printf( “%d”, x );

Read Details

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 Details

What is the output of the following code? #include#includein…

What is the output of the following code? #include#includeint main(int argc, char *argv[]){    char str1[] = “hello world”;    char str2[] = “hello world”;    if (strcmp(str1, str2))        printf(“equal”);    else        printf(“unequal”);}

Read Details

Consider this code to get user input for a string: char str…

Consider this code to get user input for a string: char str[ 3 ]; scanf( “%s”, str ); What happens if the user enters a string that is 100 characters long?

Read Details

Given 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 Details

Write 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 Details

Given 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 Details

Write 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 Details

Given 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

For this array: int a[  ] = { 0, 1, 2, 3, 4 } What is the le…

For this array: int a[  ] = { 0, 1, 2, 3, 4 } What is the length of this array?

Read Details

Posts pagination

Newer posts 1 … 1,006 1,007 1,008 1,009 1,010 … 80,287 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top