日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言数组-1_C数组-智能问题与解答

發布時間:2023/12/1 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言数组-1_C数组-智能问题与解答 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

c語言數組-1

C programming Arrays (One-D Array, Two-D Array) Aptitude Questions and Answers : In this section you will find C Aptitude Questions and Answers on One Dimensional (1D) and Two Dimensional (2D) array.

C編程數組(一維數組,二維數組)能力問題:在本節中,您將找到關于一維(1D)和二維(2D)數組的C能力問題。

C編程數組(一維,二維)智能問題列表 (List of C programming Array (One, Two Dimensional) Aptitude Questions and Answers)

1) What will be the output of following program ? #include <stdio.h> int main() {static int var[5];int count=0;var[++count]=++count;for(count=0;count<5;count++)printf("%d ",var[count]);return 0; }
  • 0 1 0 0 0

  • 0 2 0 0 0

  • 0 0 2 0 0

  • 0 0 0 0 0

  • Answer Correct Answer - 3
    0 0 2 0 0
    1)以下程序的輸出是什么?
  • 0 1 0 0 0

  • 0 2 0 0 0

  • 0 0 2 0 0

  • 0 0 0 0 0

  • 回答 正確答案-3
    0 0 2 0 0
    2) What will be the output of following program ? (for 32 bits compiler) #include <stdio.h> int main() {int MAX=10;int array[MAX];printf("size of array is = %d",sizeof(array);return 0; }
  • size of array is = 20

  • size of array is = 40

  • size of array is = 4

  • Error

  • Answer Correct Answer - 2
    size of array is = 40
    2)以下程序的輸出是什么? (用于32位編譯器)
  • 數組的大小= 20

  • 數組的大小是= 40

  • 數組的大小為= 4

  • 錯誤

  • 回答 正確答案-2
    數組的大小是= 40
    3) What will be the output of following program ? #include <stdio.h> #define MAX 10 int main() { int array[MAX]={1,2,3},tally;for(tally=0;tally< sizeof(array)/sizeof(int);tally+=1)printf("%d ",*(tally+array));return 0; }
  • Error

  • 1 3 4 5 6 7 8 9 10 11

  • 1 2 3 0 0 0 0 0 0 0

  • 0 0 0 0 0 0 0 0 0 0

  • Answer Correct Answer - 3
    1 2 3 0 0 0 0 0 0 0.
    You can also access the array elements using *(counter_variable+array_name). 3)以下程序的輸出是什么?
  • 錯誤

  • 1 3 4 5 6 7 8 9 10 11

  • 1 2 3 0 0 0 0 0 0 0

  • 0 0 0 0 0 0 0 0 0 0

  • 回答 正確答案-3
    1 2 3 0 0 0 0 0 0 0。
    您還可以使用*(counter_variable + array_name)訪問數組元素。 .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> int main() { static int x[]={'A','B','C','D','E'},tally;for(tally=0;tally< sizeof(x)/sizeof(int) ; tally+=1)printf("%c,%c,%c\n",*(x+tally)+1,x[tally]+1,*(tally+x)+1);return 0; }
  • Error

  • A,A,A
    B,B,B
    C,C,C
    D,D,D
    E,E,E

  • B,B,B
    C,C,C
    D,D,D
    E,E,E
    F,F,F

  • E,E,E
    D,D,D
    C,C,C
    B,B,B
    A,A,A

  • Answer Correct Answer - 3
    B,B,B
    C,C,C
    D,D,D
    E,E,E
    F,F,F
    4)以下程序的輸出是什么?
  • 錯誤

  • A,A,A
    B,B,B
    C,C,C
    D,D,D
    E,E,E

  • B,B,B
    C,C,C
    D,D,D
    E,E,E
    F,F,F

  • E,E,E
    D,D,D
    C,C,C
    B,B,B
    A,A,A

  • 回答 正確答案-3
    B,B,B
    C,C,C
    D,D,D
    E,E,E
    F,F,F
    5) What will be the output of following program ? #include <stdio.h> int main() { static int array[]={10,20,30,40,50};printf("%d...%d",*array,*(array+3)* *array);return 0; }
  • Error

  • 10...40

  • 10...300

  • 10....400

  • Answer Correct Answer - 4
    10...400
    In expression printf("%d...%d",*array,*(array+3)* *array);, *array is 10, *(array+3) is 40. 5)以下程序的輸出是什么?
  • 錯誤

  • 10 ... 40

  • 10 ... 300

  • 10 .... 400

  • 回答 正確答案-4
    10 ... 400
    在表達式中printf(“%d ...%d”,* array,*(array + 3)* * array); ,* array是10 ,*(array + 3)是40 。 6) What will be the output of following program ? #include <stdio.h> int main() { int a[5]={1,2,3,4,5},b[5]={10,20,30,40,50},tally;for(tally=0;tally< 5;++tally)*(a+tally)=*(tally+a)+ *(b+tally);for(tally=0;tally< 5;tally++)printf("%d ",*(a+tally));return 0; }
  • 1 2 3 4 5

  • 10 20 30 40 50

  • 11 22 33 44 55

  • Error

  • Answer Correct Answer - 3
    11 22 33 44 55
    This is a simple program to add elements of two arrays, you can access array elements using *(tally+a) Or *(b+tally) Or a[tally] . 6)以下程序的輸出是什么?
  • 1 2 3 4 5

  • 10 20 30 40 50

  • 11 22 33 44 55

  • 錯誤

  • 回答 正確答案-3
    11 22 33 44 55
    這是一個添加兩個數組元素的簡單程序,您可以使用*(tally + a)或*(b + tally)或a [tally]訪問數組元素。 .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> int main() { int a[5]={0x00,0x01,0x02,0x03,0x04},i;i=4;while(a[i]){printf("%02d ",*a+i);--i;}return 0; }
  • 00 01 02 03 04

  • 04 03 02 01 00

  • 04 03 02 01

  • 01 02 03 04

  • Answer Correct Answer - 3
    04 03 02 01
    0x00,0x01,0x02,0x03,0x04,0x05 are hex values of 0,1,2,3,4,5.
    while(a[i]) will be terminated by a[0], becuase value of a[0] is 0 hence, 04,03,03,01 will print. 7)以下程序的輸出是什么?
  • 00 01 02 03 04

  • 04 03 02 01 00

  • 04 03 02 01

  • 01 02 03 04

  • 回答 正確答案-3
    04 03 02 01
    0x00,0x01,0x02,0x03,0x04,0x05是十六進制值0、1、2、3、4、5。
    while(a [i])將以a [0]終止,因為a [0]的值為0,因此將打印04、03、03、01。 8) What will be the output of following program ? #include <stdio.h> int main() {char X[10]={'A'},i;for(i=0; i<10; i++)printf("%d ",X[i]);return 0; }
  • A 0 0 0 0 0 0 0 0 0

  • A

  • A 32 32 32 32 32 32 32 32 32

  • ERROR

  • Answer Correct Answer - 1
    A 0 0 0 0 0 0 0 0 0
    char X[10]={'A'}; 0th index of X is assigned by 'A' and rest of elements is assigned by 0. 8)以下程序的輸出是什么?
  • A 0 0 0 0 0 0 0 0 0

  • 一個

  • A 32 32 32 32 32 32 32 32 32

  • 錯誤

  • 回答 正確答案-1
    A 0 0 0 0 0 0 0 0 0
    字符X [10] = {'A'}; X的 0 索引由“ A”分配,其余元素由0分配。 9) Which is an incorrect declaration of one dimensional array ?
  • int x[5];

  • int x[5]={1,2,3,4,5};

  • int x[5]={1,2};

  • int x[];

  • Answer Correct Answer - 4

    int x[];
    You can ignore value within the subscript [] when you are initialising array with elements, but here no initialisation found.

    9)哪個是一維數組的不正確聲明?
  • int x [5];

  • int x [5] = {1,2,3,4,5};

  • int x [5] = {1,2};

  • int x [];

  • 回答 正確答案-4

    int x [];
    當您使用元素初始化數組時,可以忽略下標[]中的值,但是在此找不到初始化。

    翻譯自: https://www.includehelp.com/c-programs/c-arrays-aptitude-questions-and-answers.aspx

    c語言數組-1

    總結

    以上是生活随笔為你收集整理的c语言数组-1_C数组-智能问题与解答的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。