仓库操作员能力矩阵_C操作员-能力问题与解答

本文提供了关于C语言运算符的多项选择题和答案,涵盖了算术、赋值、复合赋值、关系运算符等,旨在测试和提升C编程操作员的能力。
摘要由CSDN通过智能技术生成

仓库操作员能力矩阵

C programming Operators Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on various Operators like Arithmetic, Assignment, Compound Assignment, Relation Operators etc.

C编程运算符能力问题:在本节中,您将找到有关算术,赋值,复合赋值,关系运算符等各种运算符的C能力问题。

C编程操作员能力倾向问题列表 (List of C programming Operators Aptitude Questions and Answers)

1) What will be the output of following program ?
#include <stdio.h>
void main()
{
       
    printf("value is = %d",(10++));
}

  1. 10

  2. 11

  3. 0

  4. ERROR

Answer & Explanation

Correct Answer - 4
Error : L-value required

++/-- operator works on variables only.

1)以下程序的输出是什么?
  1. 10

  2. 11

  3. 0

  4. 错误

答案与解释

正确答案-4
错误:需要L值

++ /-运算符仅对变量起作用。

2) What will be the output of following program ?
#include <stdio.h>
void main()
{
       
	const char var='A';
	++var;
	printf("%c",var);
}

  1. B

  2. A

  3. ERROR

  4. 66

Answer & Explanation

Correct Answer - 3
Error : increment of read-only variable 'var'.

++/-- operator works on variables only, we can not change the value of a const.

2)以下程序的输出是什么?
  1. 一个

  2. 错误

  3. 66

答案与解释

正确答案-3
错误:只读变量'var'的增量。

++ /-运算符仅对变量起作用,我们不能更改const的值。

3) What will be the output of following program ?
#include <stdio.h>
void main()
{
       
	int x=10;
	x+=(x++)+(++x)+x;
	printf("%d",x);
}

  1. 44

  2. 45

  3. 46

  4. 47

Answer & Explanation

Correct Answer - 2
45

1) expand the expression : x=x+(x++)+(++x)+x;
2) due to pre increment ++x , x will be 11 for this expression.
3) after executing expression x will be 44.
4) finally x will be 45 due to post increment (x++).

Note: the output of pre and post increment based operators may not same on all the compilers, in GCC Linux compiler output will be 46 and in TurboC output will be 45.

3)以下程序的输出是什么?
  1. 44

  2. 45

  3. 46

  4. 47

答案与解释

正确答案-2
45

1)扩展表达式: x = x +(x ++)+(++ x)+ x;
2)由于预递增++ x ,因此该表达式的x将为11。
3)执行表达式后, x将为44。
4)最后,由于后期增量( x ++ ), x将为45。

注意:在所有编译器上,基于前后增量运算符的输出可能并不相同,在GCC Linux编译器中输出为46,在TurboC输出中为45。

4) What will be the output of following program ?
#include <stdio.h>
void main()
{
       
	int a=10,b=2,x=0;
	x=a+b*a+10/2*a;
	printf("value is =%d",x);
}

  1. valie is =1250

  2. value is =80

  3. value is =125

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值