What are the contents of the array after this declaration and initialization? int a[ 10 ] = { 5, 7, 8, 9, 11 };
Blog
What is the switch/case equivalent of the following nested i…
What is the switch/case equivalent of the following nested if/else block? if( option == 0 || option == 1 ){ value = 10;} else if( option == 2 ){ value = 20;} else{ value = 30;}
What should the parameters for the main function be in C?
What should the parameters for the main function be in C?
Predict the Output: int a = 5;if (a == 5 || a == 10 && a ==…
Predict the Output: int a = 5;if (a == 5 || a == 10 && a == 15) printf(“True”);else printf(“False”); Explain what is printed and why? Consider the code is fully formed, i.e., no excuses like missing main(), missing stdio.h, etc.
Predict the Output: printf(“%d”, sizeof((char)’A’)); print…
Predict the Output: printf(“%d”, sizeof((char)’A’)); printf(“%d”, sizeof(‘A’)); Explain what is printed and why? Consider the code is fully formed, i.e., no excuses like missing main(), missing stdio.h, etc.
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.
Write a logic that prints the following pattern, based on th…
Write a logic that prints the following pattern, based on the input value for N. Concentrate on your loop logic, variables, and printf() statements. Once you come up with a formula, the implementation should be a cakewalk. For example, for N = 4: Row 1 (or any odd-numbered row): Print 4 integers starting with 10*(row_no), and incrementing by 2 on each step. Row 2 (or any even-numbered row): Print 4 integers starting with 10*(row_no+1), and decrementing by 2 on each step. If N=3, it should print10 12 1430 28 2630 32 34 If N = 4, it should print10 12 14 1630 28 26 2430 32 34 3650 48 46 44
Write a logic that prints the following pattern, based on th…
Write a logic that prints the following pattern, based on the input value for N. Concentrate on your loop logic, variables, and printf() statements. Once you come up with a formula, the implementation should be a cakewalk. For example, for N = 4: Row 1 (or any odd-numbered row): Print 4 integers starting with 10*(row_no)+1, and incrementing. Row 2 (or any even-numbered row): Print 4 integers starting with 10*(row_no+1)-1, and decrementing. If N=3, it should print11 12 1329 28 2731 32 33 If N = 4, it should print11 12 13 1429 28 27 2631 32 33 3449 48 47 46
Predict the Output: int a = 5;while(a = 0) { printf(“Loop…
Predict the Output: int a = 5;while(a = 0) { printf(“Loop”);}printf(“Done”); Explain what is printed and why? Consider the code is fully formed, i.e., no excuses like missing main(), missing stdio.h, etc.
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?