SP2 Contest 1Last Updated : 03 Nov, 2020ReadDiscussCoursesSP2 Contest 1Please wait while the activity loads.If this activity does not load, try refreshing your browser. Also, this page requires javascript. Please visit using a browser with javascript enabled.If loading fails, click here to try againQuestion 1Predict the output of below C program: #include<stdio.h> int main() { int a = 5, b = 10%9, i; for(i=1; i<10; i++) if(a != b); printf("a = %d b = %dn", a, b); return 0; } 5 1Prints “a = 5 b = 1” ten times.a = 5 b = 1The program will not produce any outputSP2 Contest 1 Discuss itQuestion 1-Explanation: The printf statement is outside the if block because of the semicolon operator after the if statement and thus it is also outside the for loop block. So, it is executed only once.Question 2Predict the output of the below C program: C #include <stdio.h> int main() { int i = 2, j = -2; if((printf("%d", j)) < (printf("%d", i))) printf("%d", i); else printf("%d", j); return 0; } 2-22-22-2222Compilation ErrorSP2 Contest 1 Discuss itQuestion 2-Explanation: We know that printf() returns the number of character it prints. Hence printf(“%d”,j) will return -2 and newline i.e. 3 characters, and printf(“%d”, i) will return 2 and newline i.e. 2. Thus if statement will look like (3 > 2) which is false. So the else block is executed followed by the execution of printf() statements within the if condition.Question 3What will be the output of the below C program? #include <stdio.h> int main() { int a = 2; if("%d=gfg", a); return 0; } Compilation Error2=gfgNo Output2SP2 Contest 1 Discuss itQuestion 3-Explanation: There is no printf() statement in the above program, so the program will not print any output. Also, the program is syntactically error-free so there is no compilation error.Question 4What will be the output of the below C program? #include <stdio.h> int main() { int x = 2; do{ ++x; printf("%d", x); } while(--x <= 2); return 0; } Runtime Error23Infinite LoopSP2 Contest 1 Discuss itQuestion 4-Explanation: As the value of x is incremented(++x) and then decremented(--x), hence no change in the value of x will occur and it will be as 2.Question 5What will be the output of below C++ program? #include <iostream> using namespace std; int main() { float _ = 20.5; int __ = 20; cout<< __ + _ <<endl; return 0; } Runtime ErrorCompile Time Error__+_40.5SP2 Contest 1 Discuss itQuestion 5-Explanation: Underscore(_) and double underscores(__) can be used as variable names.Question 6Predict the output of the below C program: #include <stdio.h> int main() { int a = - -3; printf("a=%d", a); return 0; } a=3a=-3a=2None of the aboveSP2 Contest 1 Discuss itQuestion 6-Explanation: Notice the space between the two minus(-) operators. Here unary operation minus(-) is applied twice instead of the pre-decrement operator, we know in maths that minus*minus gives plus. Therefore, - -3 = -(-3) = 3.Question 7Predict the output of the below C program: #include <stdio.h> int main() { int a = 5, b, c = 15, d = 13; b = (a = c, c += a, d = a + c + d); printf("%d %d %d %d", a,c,b,d); return 0; } 5 30 0 5815 30 58 5815 30 0 585 30 58 33SP2 Contest 1 Discuss itQuestion 7-Explanation: The variable b is assigned the value of the rightmost expression that is (d = a+b+c) = 58.Question 8Which of the following statement(s) is/are true about Associativity and Precedence of operators in C.Associativity is only used when there are two or more operators of the same precedence.All operators with the same precedence have the same associativity.Precedence and associativity of postfix ++ and prefix ++ are same.Comma operator has the highest precedence among all operators.Only 1Only 3Both 1 and 2Both 2 and 3SP2 Contest 1 Discuss itQuestion 8-Explanation: Please refer: https://www.geeksforgeeks.org/c-operator-precedence-associativity/Question 9What will be the output of the below C program? #include <stdio.h> int main() { if (sizeof(int) > -10) printf("YES"); else printf("NO"); return 0; } YESNOYESNOCompilation ErrorSP2 Contest 1 Discuss itQuestion 9-Explanation: In C, when an integer value is compared with an unsigned int, the int is promoted to unsigned. Negative numbers are stored in 2's complement form and unsigned value of the 2's complement form is much higher than the sizeof int.Question 10Which of the following statement(s) is/are True about Data-Types in C?If no data type is given to a variable, then the compiler automatically convert it to int data type.Signed is the default modifier for char and int data types.We can use any modifiers in the float data type.We can use any modifiers in double data type.Only 1Only 3Both 1 and 2All of the aboveSP2 Contest 1 Discuss itQuestion 10-Explanation: Please refer: https://www.geeksforgeeks.org/interesting-facts-about-data-types-and-modifiers-in-c-cpp/ 12345 There are 50 questions to complete.You have completedquestionsquestionYour accuracy isCorrectWrongPartial-CreditYou have not finished your quiz. If you leave this page, your progress will be lost.Correct AnswerYou SelectedNot AttemptedFinal Score on QuizAttempted Questions CorrectAttempted Questions WrongQuestions Not AttemptedTotal Questions on QuizQuestion DetailsResultsDateScoreHintTime allowedminutessecondsTime usedAnswer Choice(s) SelectedQuestion Text All doneNeed more practice!Keep trying!Not bad!Good work!Perfect!