c# 情感倾向_C否则-能力倾向问题与解答
c# 情感傾向
C programming if else Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on condition statements – if else, nested if else, ladder if else, conditional operators etc.
C語(yǔ)言編程如果有問(wèn)題,請(qǐng)執(zhí)行以下步驟:在本節(jié)中,您將找到條件語(yǔ)句的C語(yǔ)言問(wèn)題和答案-如果有,則嵌套,如果有則階梯,有條件的運(yùn)算符等。
1) What will be the output of following program ? #include <stdio.h> void main() {if(!printf(""))printf("Okkk");elseprintf("Hiii"); }Okkk
Hiii
Error
None
Okkk 1)以下程序的輸出是什么?
Okkk
iii
錯(cuò)誤
沒(méi)有
Okkk 2) What will be the output of following program ? #include <stdio.h> void main() {int x=22;if(x=10)printf("TRUE");elseprintf("FALSE"); }
TRUE
FALSE
Error
None
TRUE
if(x=10)... "=" is an assignment operator, so 10 will be assigned to x and condition will be true due to if(10).. 2)以下程序的輸出是什么?
真正
假
錯(cuò)誤
沒(méi)有
真正
if(x = 10)...“ =”是一個(gè)賦值運(yùn)算符,因此由于if(10) ,x將賦給10,并且條件為true。 3) What will be the output of following program ? #include <stdio.h> void main() {char val=1;if(val--==0)printf("TRUE");elseprintf("FALSE"); }
FALSE
Error
TRUE
None
FALSE 3)以下程序的輸出是什么?
假
錯(cuò)誤
真正
沒(méi)有
假 .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} 4) What will be the output of following program ? #include <stdio.h> void main() {float a=10.5;printf("\n===FIRST CONDITION\n");if(sizeof(a)==sizeof(10.5))printf("Matched !!!");elseprintf("Not matched !!!");printf("\n===SECOND CONDITION\n");if(sizeof(a)==sizeof(10.5f))printf("Matched !!!");elseprintf("Not matched !!!");printf("\n===THIRD CONDITION\n");if(sizeof((double)a)==sizeof(10.5))printf("Matched !!!");elseprintf("Not matched !!!");printf("\n===FOURTH CONDITION\n");if(a==10.5f)printf("Matched !!!");elseprintf("Not matched !!!");printf("\n"); } Answer ===FIRST CONDITION
Not matched !!!
===SECOND CONDITION
Matched !!!
===THIRD CONDITION
Matched !!!
===FOURTH CONDITION
Matched !!!
in this program a is a float variable and value 10.5 will consider as double. 4)以下程序的輸出是什么? 回答 ===第一條件
不匹配!
===第二條件
匹配!
===第三條件
匹配!
===第四條件
匹配!
在此程序中,a是一個(gè)浮點(diǎn)變量,值10.5將被視為double。 5) What will be the output of following program ? #include <stdio.h> int main() {int a=10;if(a==10){printf("Hello...");break;printf("Ok");}else{printf("Hii");}return 0; }
Hello...
Hello...OK
OK
Error
Error : misplaced break/ illegal break
A break statement can be used with looping and switch statements. 5)以下程序的輸出是什么?
你好...
你好...好
好
錯(cuò)誤
錯(cuò)誤:錯(cuò)誤放置的中斷/非法中斷
break語(yǔ)句可與循環(huán)和switch語(yǔ)句一起使用。 6) What will be the output of following program ? #include <stdio.h> int main() {if( (-100 && 100)||(20 && -20) )printf("%s","Condition is true.");elseprintf("%s","Condition is false.");return 0; }
Condition is true.
Condition is false.
No output
ERROR
Condition is true.
Any non zero value is treated as true for conidion.
Consider the expressions: if( (-100 && 100)||(20 && -20) )
=if( (1) || (1) )
=if(1)
6)以下程序的輸出是什么?
條件為真。
條件為假。
無(wú)輸出
錯(cuò)誤
條件為真。
對(duì)于任何條件,任何非零值均視為true。
考慮以下表達(dá)式:if((-100 && 100)||((20 && -20))
= if((1)||(1))
=如果(1)
.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} 7) What will be the output of following program ? #include <stdio.h> #define TRUE 1 int main() {if(TRUE)printf("1");printf("2");elseprintf("3");printf("4");return 0; }
ERROR
1
12
2
ERROR : misplaced if/illegal else without matching if.
You can use only one statement within the if( )without parenthesis {...} .
7)以下程序的輸出是什么?
錯(cuò)誤
1個(gè)
12
2
錯(cuò)誤:如果/錯(cuò)誤放置,否則不匹配。
沒(méi)有括號(hào){...}的if()中只能使用一個(gè)語(yǔ)句。
8) What will be the output of following program ? #include <stdio.h> int main() {int pn=100;if(pn>20)if(pn<20)printf("Heyyyyy");elseprintf("Hiiiii");return 0; }
No output
Hiiiii
Heyyyyy
HeyyyyyHiiiii
Hiiiii
printf("Hiiiii"); that is written after else , is treated as else part of inner if condition if(pn<20). 8)以下程序的輸出是什么?
無(wú)輸出
i
嘿嘿
HeyyyyyHiiiii
i
printf(“ Hiiiii”); 在else后面寫(xiě)入的內(nèi)容被視為if條件if(pn <20)的內(nèi)部else部分。 9) Which of the following are incorrect statements? If int a=10. 1) if( a==10 ) printf("IncludeHelp"); 2) if( 10==a ) printf("IncludeHelp"); 3) if( a=10 ) printf("IncludeHelp"); 4) if( 10=a ) printf("IncludeHelp");
3 and 4.
3 only.
4 only.
2,3 and 4.
4 only.
Consider the following expressions:
if(a==10) => if(1) => correct.
if(10==a) => if(1) => correct.
if(a=10) => if(10) => correct (10 is a non zero value).
if(10=a) => incorrect, because value of a can not assign in 10, Lvalue required error is occurred. 9)以下哪項(xiàng)是不正確的陳述? 如果int a = 10。
3和4。
僅3個(gè)。
僅4個(gè)。
2,3和4。
僅4個(gè)。
請(qǐng)考慮以下表達(dá)式:
if(a == 10) => if(1)=>正確。
if(10 == a) => if(1)=>正確。
if(a = 10) => if(10)=>正確(10是一個(gè)非零值)。
if(10 = a) =>錯(cuò)誤,因?yàn)椴荒茉?0中分配a的值,所以發(fā)生了Lvalue必需的錯(cuò)誤。 10) What will be the output of following program ? #include <stdio.h> int main() {int a=10;if(10L == a)printf("10L");else if(10==a)printf("10");elseprintf("0");return 0; }
10.
10L.
10L10.
ERROR.
10L.
10)以下程序的輸出是什么?
10。
10升
10L10。
錯(cuò)誤。
10升
翻譯自: https://www.includehelp.com/c-programs/c-if-else-aptitude-questions-and-answers.aspx
c# 情感傾向
總結(jié)
以上是生活随笔為你收集整理的c# 情感倾向_C否则-能力倾向问题与解答的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Java LocalDate类| toS
- 下一篇: kotlin 第一个程序_Kotlin程