c语言输入数字存到数组中并输出
时间: 2023-05-21 15:07:04 浏览: 667
您好!以下是将C语言中输入的数字存储到数组中并输出的代码示例:
```c
#include <stdio.h>
int main() {
int nums[10];
int i;
printf("请依次输入10个数字:\n");
for (i=0; i<10; i++) {
scanf("%d", &nums[i]);
}
printf("您输入的数字为:");
for (i=0; i<10; i++) {
printf("%d ", nums[i]);
}
return 0;
}
```
希望对您有帮助!
相关问题
c语言向数组输入数字
在C语言中,向数组输入数字可以通过循环结构和scanf函数实现。具体步骤如下:
1.定义一个数组并确定数组的大小。
```c
#define SIZE 5
int arr[SIZE];
```
2.使用for循环结构,通过scanf函数向数组中输入数字。
```c
for(int i=0; i<SIZE; i++){
scanf("%d", &arr[i]);
}
```
3.输入完成后,可以通过for循环结构和printf函数将数组中的数字输出。
```c
for(int i=0; i<SIZE; i++){
printf("%d ", arr[i]);
}
```
阅读全文
相关推荐













