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;
}
  1. 0 1 0 0 0

  2. 0 2 0 0 0

  3. 0 0 2 0 0

  4. 0 0 0 0 0

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

  2. 0 2 0 0 0

  3. 0 0 2 0 0

  4. 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;
}

  1. size of array is = 20

  2. size of array is = 40

  3. size of array is = 4

  4. Error

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

  2. 數組的大小是= 40

  3. 數組的大小為= 4

  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;
}

  1. Error

  2. 1 3 4 5 6 7 8 9 10 11

  3. 1 2 3 0 0 0 0 0 0 0

  4. 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. 錯誤

  2. 1 3 4 5 6 7 8 9 10 11

  3. 1 2 3 0 0 0 0 0 0 0

  4. 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)訪問數組元素。
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;
}

  1. Error

  2. A,A,A
    B,B,B
    C,C,C
    D,D,D
    E,E,E

  3. B,B,B
    C,C,C
    D,D,D
    E,E,E
    F,F,F

  4. 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)以下程序的輸出是什么?
  1. 錯誤

  2. A,A,A
    B,B,B
    C,C,C
    D,D,D
    E,E,E

  3. B,B,B
    C,C,C
    D,D,D
    E,E,E
    F,F,F

  4. 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;
}

  1. Error

  2. 10...40

  3. 10...300

  4. 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)以下程序的輸出是什么?
  1. 錯誤

  2. 10 ... 40

  3. 10 ... 300

  4. 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. 1 2 3 4 5

  2. 10 20 30 40 50

  3. 11 22 33 44 55

  4. 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. 1 2 3 4 5

  2. 10 20 30 40 50

  3. 11 22 33 44 55

  4. 錯誤

回答
正確答案-3
11 22 33 44 55
這是一個添加兩個數組元素的簡單程序,您可以使用*(tally + a)或*(b + tally)或a [tally]訪問數組元素。
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;
}
  1. 00 01 02 03 04

  2. 04 03 02 01 00

  3. 04 03 02 01

  4. 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)以下程序的輸出是什么?
  1. 00 01 02 03 04

  2. 04 03 02 01 00

  3. 04 03 02 01

  4. 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;
}
  1. A 0 0 0 0 0 0 0 0 0

  2. A

  3. A 32 32 32 32 32 32 32 32 32

  4. 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)以下程序的輸出是什么?
  1. A 0 0 0 0 0 0 0 0 0

  2. 一個

  3. A 32 32 32 32 32 32 32 32 32

  4. 錯誤

回答
正確答案-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 ?
  1. int x[5];

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

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

  4. 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)哪個是一維數組的不正確聲明?
  1. int x [5];

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

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

  4. int x [];

回答
正確答案-4

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

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

c語言數組-1

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/379039.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379039.shtml
英文地址,請注明出處:http://en.pswp.cn/news/379039.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

abap 添加alv上的工具欄的按鈕_Excel里的置頂功能——快速訪問工具欄

100萬職場人都在看后臺回復禮包領199元職場干貨大家好&#xff0c;我是小可~今天跟大家分享一個提高Excel操作效率的小技巧自定義你的快速訪問工具欄設置后的效果▼▼▼也就是把你最經常用到的兩三個功能放到快速訪問工具欄可以一眼就找到這些功能不需要靠快捷鍵或者功能選項卡…

用遞歸法求12+22+...+n2的值

思路分析: 談到遞歸,我個人會聯想到數學里面的通式。因為遞歸調用的函數的對應法則是相同的。例如這道題:f(x)=x。這個就是函數通式,只不過把每個求得的結果進行累加求和即可。用戶輸入5的時候,會出現f(5)=5,之后再進行x減一操作,執行f(4)=4,最后將每個進行累加即可。…

機器學習資料推薦

機器學習資料推薦 機器學習的資料 1:斯坦福大學視頻(作為入門教程&#xff0c;網易有中文字幕&#xff0c;而且講義也有翻譯版本&#xff09;20集200左右講義 2&#xff1a;機器學習 Tom M.Mitchell(雖然出版10多年&#xff0c;但是通俗易懂的內容&#xff0c;讓讀者對機器學習…

ffplay源碼(版本:ffmpeg-4.2.1)

ffplay源碼&#xff08;版本&#xff1a;ffmpeg-4.2.1&#xff09; /** Copyright (c) 2003 Fabrice Bellard** This file is part of FFmpeg.** FFmpeg is free software; you can redistribute it and/or* modify it under the terms of the GNU Lesser General Public* Lic…

stringwriter_Java StringWriter toString()方法與示例

stringwriterStringWriter類的toString()方法 (StringWriter Class toString() method) toString() method is available in java.io package. toString()方法在java.io包中可用。 toString() method is used to represent the buffer current value in terms of string. toStr…

編寫一個函數,計算下式當n=10和n=100的值。

思路分析: 首先,我個人看法:當我拿到這道題的時候,我會把它當成一道數學題對待。分子是動的,恒為一,分母是進行依次增加的。且奇數項為正,偶數項為負。因為設計運算出現的是分數,故,設計選取存儲類型為double。 找出問題: ①正負號問題、②分母問題、③累計求和問題…

POJ 1001 大數的乘法

對這道題的理解 大數的乘法 關鍵是 實型的 那么首先就是數出來小數點有幾位這個相信很簡單 從后面往前數剛開始0 不算接著就是遇到小數點結束如果沒有小數點 那么置為0 接著就是輸出地時候首先算出小數點的位置然后輸出 你想怎么樣都行 從后往前數這個時候輸出 那么就是你也…

鈴木uy125摩托車機油_濟南鈴木安徽發布國四新車—6480元瑞夢125、9380元UY125

安徽合肥&#xff0c;這個具有兩千多年歷史的古城&#xff0c;以“三國故地、包拯家鄉”而聞名海內外&#xff0c;2019年4月22日濟南鈴木為這座城市帶來一份驚喜&#xff0c;今年正值國四執行&#xff0c;濟南鈴木旗下兩款國四新車瑞夢125與UY125正式在合肥與大家相見。濟南鈴木…

Andrej Karpathy最新大模型入門視頻講解

最近這兩天&#xff0c;特斯拉前AI總監 現在在OpenAI的安德烈卡帕西&#xff08;Andrej Karpathy&#xff09;的新教程火了 這次 他專門面向普通大眾做了一個關于大語言模型的科普視頻 時長1個小時&#xff0c;全部為“非技術介紹”&#xff0c; 涵蓋了模型推理、訓練、微…

Jquery 尋找父、子、兄弟節點

JQUERY的父&#xff0c;子&#xff0c;兄弟節點查找方法 jQuery.parent(expr) 找父親節點&#xff0c;可以傳入expr進行過濾&#xff0c;比如$("span").parent()或者$("span").parent(".class") jQuery.parents(expr),類似于jQuery.parents(exp…

編寫一個程序,計算用戶輸入的起始時間到終止時間之間相隔的天數。

思路分析&#xff1a; 閏年&#xff1a;閏年又分為普通閏年和世紀閏年 普通閏年&#xff1a;能被4整除且不能被100整除的為閏年(2004為閏年&#xff0c;1999不是閏年) 世紀閏年&#xff1a;能被400整除的是閏年(2020年是閏年&#xff0c;1900年不是閏年) 閏年共有366天&#x…

longvalue_Java Short類longValue()方法及示例

longvalue短類longValue()方法 (Short class longValue() method) longValue() method is available in java.lang package. longValue()方法在java.lang包中可用。 longValue() method is used to return the value denoted by this Short object converted to type long (by …

mvc的Controller返回值類型ActionResult詳解

一、簡介 ActionResult 操作方法通過執行工作并返回操作結果來響應用戶輸入。 操作結果表示框架將代表操作方法執行的命令。 ActionResult 類是操作結果的基類。 以下類型從 ActionResult 派生&#xff1a; ContentResult EmptyResult FileResult HttpUnauthorizedResult …

柵格布局一般怎么用_建筑混凝土色差大怎么辦?用這種方法處理,一般都看不出來...

由于模板銹蝕、脫模劑污染、原材料等原因&#xff0c;建筑混凝土成形后經常會遇到顏色不一致的現象&#xff0c;為此我們總結了混凝土面色差調整施工工藝&#xff0c;可供大家參考使用。一、混凝土面色差調整施工工藝流程及說明基層表面打磨→吸塵器吸塵→濕潤墻面→素水泥處理…

Java SimpleTimeZone equals()方法與示例

SimpleTimeZone類的equals()方法 (SimpleTimeZone Class equals() method) equals() method is available in java.util package. equals()方法在java.util包中可用。 equals() method is used to check whether this SimpleTimeZone and the given object (ob) are equals or …

FusionChart完全入門手冊4

想不想打造讓人震撼的圖表系統&#xff0c;想不想做出和別人不一樣的圖表&#xff0c;從本節起&#xff0c;我就帶領大家走入這片神奇的土地&#xff0c;讓大家去采摘屬于自己的創意之果&#xff0c;我們的目標是------個性無罪&#xff0c;個性萬歲&#xff01; 問題三、如何做…

ffplay分析(音頻解碼線程的操作)

《ffplay的數據結構分析》 《ffplay分析&#xff08;從啟動到讀取線程的操作&#xff09;》 《ffplay分析&#xff08;視頻解碼線程的操作&#xff09;》 《ffplay 分析&#xff08;音頻從Frame(解碼后)隊列取數據到SDL輸出&#xff09;》 《ffplay分析 &#xff08;視頻從Fram…

More Effective C++ (運算符)

4.1&#xff1a;謹慎定義類型轉換函數<1>容易的方法是利用一個最新的編譯器特性&#xff1a;explicit關鍵字<2>C編譯器把">>"作為一個符號來解釋&#xff0c;在兩個">"間沒有空格&#xff0c;語句會產生語法錯誤。<3>隱式類型轉…

大綱(二)

一、數據結構就是邏輯結構存儲結構(物理結構)相應操作(算法實現) 二、邏輯結構 集合1:1 線性結構1:n 樹m:n 圖 主要是可以畫到紙上進行分析的結構圖就是邏輯結構&#xff0c;分析問題可以得出唯一一個邏輯結構 三、存儲結構(物理結構) 順序存儲結構(例如:線性表)鏈式存儲結…

php微信獲取mediaid超出限制_Python實現每日微信自動打卡

眾所周知&#xff0c;因為疫情的原因&#xff0c;很多高校和公司都要求員工每日在微信上進行打卡&#xff0c;來匯報自己的當前身體狀態和所處地區。但絕大多數情況下&#xff0c;每天打卡的信息其實是不會變的&#xff0c;我們要做的就是進入公眾號——自動登錄點進打卡頁面—…