Answers for "how to input a array in c"

C
5

take array as input in c

int size=5;
int array[size]; // array of size=5;

for(i=0;i<size;i++){
   scanf("%d",&array[i]);
                }
Posted by: Guest on November-05-2020
0

input array elements in c

#include <stdio.h>

int main(){
    int i,sum,max,min,avg,size;
   
    printf("ENter array length : n");
    scanf("%d",&size);
    
    int ara[size];
    
     printf("Enter array elements:n");
     for(i = 0; i < size;  i++){
        scanf("%d", &ara[i]);
     }
     
   
    
    sum=0;
    max=ara[0];
    min=ara[0];
    for(i = 0; i < size; i++){
        printf("Your array elements are %dn",ara[i]);
        sum+=ara[i];
        if(ara[i] > max){
            max = ara[i];
        }
        if(ara[i] < min){
            min = ara[i];
        }
    }
    avg=sum/size;
    
    printf("Sum is %dn",sum);
    printf("Average is %dn",avg);
    printf("Max number is %dn",max);
    printf("Min number is %dn",min);
    
    
    return 0;
}
Posted by: Guest on July-13-2021

Code answers related to "how to input a array in c"

Code answers related to "C"

Browse Popular Code Answers by Language