Search
 
SCRIPT & CODE EXAMPLE
 

C

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]);
                }
Comment

input array elements in c

#include <stdio.h>

int main(){
    int i,sum,max,min,avg,size;
   
    printf("ENter array length : 
");
    scanf("%d",&size);
    
    int ara[size];
    
     printf("Enter array elements:
");
     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 %d
",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 %d
",sum);
    printf("Average is %d
",avg);
    printf("Max number is %d
",max);
    printf("Min number is %d
",min);
    
    
    return 0;
}
Comment

inputting an array in c

int i, arr[10];

for(i = 0; i < sizeof(arr) / sizeof(struct i); i++)
{
  cin >> (arr[i].data);
}
Comment

PREVIOUS NEXT
Code Example
C :: print variable adress c 
C :: equal string c 
C :: c functions example 
C :: simple calculator, using switch statement in C 
C :: HOW TO ADD FORM IN BOOTSTRAp 
C :: memory layout in c 
C :: how to compareTo in java 
C :: passing two dimensional array to function in c 
C :: memcpy in c 
C :: how to read 2d array from a file in c 
C :: read file c 
C :: c concatenate and allocate string 
C :: function array median 
C :: macos prevent disk mounting 
C :: how to merge 2 bytes into an integer 
C :: esp8266 wifi.config does not work 
C :: c extern 
C :: how to use pointer in c to print char 
C :: c file struct 
C :: compile in c 
C :: increment pointer value in c 
C :: ecto where is not nil 
C :: arduino internal pull up resistor 
C :: C static libraries (Indexing an archive) 
C :: esp local control 
C :: uninstall elgg from hostgtor 
C :: Print Characters 
C :: condition ternaire in c 
C :: switch every right 4 bit with the left 4 bits 
C :: function that reverses the content of an array of integers. 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =