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

Array Input/Output in C

// Program to take 5 values from the user and store them in an array
// Print the elements stored in the array
#include <stdio.h>

int main() {
  int values[5];

  printf("Enter 5 integers: ");

  // taking input and storing it in an array
  for(int i = 0; i < 5; ++i) {
     scanf("%d", &values[i]);
  }

  printf("Displaying integers: ");

  // printing elements of an array
  for(int i = 0; i < 5; ++i) {
     printf("%d
", values[i]);
  }
  return 0;
}
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

C Input and Output Array Elements

// take input and store it in the 3rd element
​scanf("%d", &mark[2]);

// take input and store it in the ith element
scanf("%d", &mark[i-1]);
Comment

PREVIOUS NEXT
Code Example
C :: c check if array is empty 
C :: c style string 
C :: comment in c language 
C :: addition.c 
C :: C Passing Pointers to Functions 
C :: putchar in c 
C :: geom boxplot remove outliers 
C :: add_to_cart how to call it woocommerce 
C :: C program to check whether character is lowercase or not using ASCII values 
C :: how i send custom data in model field rest_framework serializer 
C :: Passing a matrix in a function C 
C :: c loop 
C :: malloc basics 
C :: dynamic memory allocation c 
C :: convert string to int error checking c 
C :: how to take comma separated integer input in c 
C :: hourglass sum 
C :: signed and unsigned in c 
C :: square in c 
C :: print 100 times c 
C :: read from command line c 
C :: %g and %e in c 
C :: objects in oops 
C :: c convert float to int 
C :: swap using third variable 
C :: modelform prefill with data 
C :: block quote in lua 
C :: epita 
C :: remove every appearance of char without malloc in c 
C :: Program to Find Swap Numbers Using Temporary Variable 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =