首页 > 解决方案 > 编写 C 程序供用户输入 50 或更少的数字

问题描述

我正在尝试编写一个 C 程序,该程序必须要求用户输入 50 个或更少的数字。我的问题是“或更少”的数字。如何让程序知道用户何时想要停止输入数字?

标签: cuser-input

解决方案


这是您问题的答案:-

#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
void main()
{
    int a[100],n,i;
    printf("Enter the no of inputs u want to give (It must be less than or eqaual to 50)\n");
    scanf("%d",&n);
    printf("Enter the nos \n");
    if(n<=50)
    {
    for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
}
    }
    else
        printf("Invalid Input \n");
        getch();
}

推荐阅读