Calculating the sum of integers in an array

后端 未结 9 1505
我在风中等你
我在风中等你 2021-01-19 03:11

I don\'t know if I\'m just being a total fool, most likely I am, it\'s been a long day, but this isn\'t working as I want it to, and, well, I don\'t see why.

It sho

9条回答
  •  逝去的感伤
    2021-01-19 03:50

    If an array is a[10], then every array starts from its index number 0, so here it will have 10 elements; given that their positions will start from 0 to 9, counting gives 10 elements.

    You can try this:

    main()         
    {        
        int a[10], i, n, sum=0;    
    
        printf("enter no. of elements");
        scanf("%d",&n); 
        printf("enter the elements");   
    
        for(i=0;i

提交回复
热议问题