Dynamic array Usage

Source: Internet
Author: User

1#include <stdio.h>2#include <stdlib.h>3 4 intMain ()5 {6     inti;7     intN//the number of integers used to record input8     int*p;//storage space for pointing to a dynamic array9     intsum=0, average;//The and and average values of the integers used to record inputsTen      Onescanf"%d", &n);//Enter the number of integers to be entered n A      -P=calloc (N,sizeof(int));//dynamically allocate n length to sizeof (int) Continuous space--dynamic array (number of array elements n, type int) -      the      for(i=0; i<n;i++)//Enter n integers -scanf"%d", p+i); -          -      for(i=0; i<n;i++)//sum +sum+=* (p+i); -average=sum/n;//Find Average +      A     //Output atprintf"%d%d", sum,average); -      -     return 0; -}

Dynamic array Usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.