关闭

some basic interview question

标签: c
240人阅读 评论(0) 收藏 举报
分类:

(the header is omitted,sorry)
1.about the pointer and the ++ ,–

int main()
{
    int x = 4;
    int *p = &x;
    int *k = p++;
    int r = p - k;
    printf("%d", r);
}

>
explain:
C本身无法防止非法的指针减法运算,它无法为你提出任何警告或提示。
for more information
(http://blog.csdn.net/gdmmhym/article/details/6451554)
2.

int main()
{
unsigned int i = 23;
signed char c = -23;
if (i > c)
printf("Yes\n");
else if (i < c)
printf("No\n");
}

answer :No
for more information
(http://blog.csdn.net/ljianhui/article/details/10367703)
3.

int main()
{
    int x = -2;
    x = x >> 1;
    printf("%d\n", x);
}

answer:-1
it is simple,but i just want to write it here.
4.8. What is the output of this C code?

int main()
{
    int y = 1;
    if (y & (y = 2))
        printf("true %d\n", y);
    else
        printf("false %d\n", y);

}

a) true 2
b) false 2
c) Either option a or option b
d) true 1
View Answer

Answer:c

5.
void main()
{
char a = ‘a’;
int x = (a % 10)++;
printf(“%d\n”, x);
}
answer:compile error
please note that :
[Error] lvalue required as increment operand
6.concentrate on the detail
example 1:
void main()
{
1 < 2 ? return 1: return 2;
}

answer:compile error
note that the ‘return 1’ is not a expression
example 2:

int main()
{
int x = 1, y = 0;
x &&= y;
printf("%d\n", x);
}

please note that ‘&&= ’ does not exist
+=、-=、*=、/=、%=、<<=、>>=、&=、^=、|=
here
example 3

int main()
{
int y = 1, x = 0;
int l = (y++, x++) ? y : x;
printf(“%d\n”, l);
}
a) 1
b) 2
c) Compile time error
d) Undefined behaviour
View Answer

Answer:a

7.some thing i want to figure out ,

int main()
{
    int x = 1;
    short int i = 2;
    float f = 3;
    if (sizeof((x == 2) ? f : i) == sizeof(float))
        printf("float\n");
    else if (sizeof((x == 2) ? f : i) == sizeof(short int))
        printf("short int\n");
}

0
0
查看评论

中山大学算法课程题目详解(第十周)

问题描述: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximu...
  • weimumu0515
  • weimumu0515
  • 2017-11-27 18:49
  • 72

VLSI Interview question (2)

Below interview questions are contributed by ASIC_diehard (Thanks a lot !). Below questions are asked for senior position in Physical Design domain...
  • feiyang756
  • feiyang756
  • 2014-04-30 00:06
  • 1835

SQL Interview Questions

SQL Interview Questions
  • xinxin19881112
  • xinxin19881112
  • 2016-03-22 09:36
  • 292

Core Java Interview Questions and Answers

Whether you are a fresher or highly experienced professional, core java plays a vital role in any Java/JEE interview. Core Java is the fav...
  • doctor_who2004
  • doctor_who2004
  • 2014-12-27 16:30
  • 872

16个behavior question 的面试官解析及tips(上)

除了技术面试,behavior interview也是程序员拿到offer必经的一道关口。九章算法总结了16个常见的behavior question,并解析面试官想通过这些问题考察的内容,指出需要避免的“坑”,并提供了一些小建议。希望对大家找工作有帮助。
  • JiuZhang_ninechapter
  • JiuZhang_ninechapter
  • 2015-05-26 13:38
  • 2910

前端面试题Front-end Job Interview Questions

Front-end Job Interview Questions This file contains a number of front-end interview questions that can be used when vetting potential candidates. It...
  • GarfieldEr007
  • GarfieldEr007
  • 2016-03-11 12:37
  • 1183

Interview question

Q: Can you sell yourself in two minutes? Go for it. (你能在两分钟內自我推荐吗?大胆试试吧!) A: With my qualifications and experience, I feel I am hardworking, responsib...
  • laolao2000_0
  • laolao2000_0
  • 2005-10-26 11:02
  • 1458

interview question

http://www.ardendertat.com/2012/01/09/programming-interview-questions/ http://www.ardendertat.com/2011/05/30/how-to-implement-a-search-engine-part-1-...
  • bachelorchen
  • bachelorchen
  • 2015-05-07 14:19
  • 206

some question

1.如何合理的控制版本。 答:a. 主干master: 维护最稳定的代码。       b. 开发分支develop: 维护开发的代码,开发完一个稳定的功能后合并回master。       c. 紧急bug分支 hotfixes: 开发过...
  • JavaLive09
  • JavaLive09
  • 2013-05-09 14:46
  • 514

【LeetCode 7. Reverse Integer】& Pytohn 语法熟悉

题面: Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Exampl...
  • WYK1823376647
  • WYK1823376647
  • 2018-01-03 21:23
  • 37
    个人资料
    • 访问:16190次
    • 积分:652
    • 等级:
    • 排名:千里之外
    • 原创:48篇
    • 转载:1篇
    • 译文:0篇
    • 评论:8条
    文章分类
    最新评论