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

array value from user c

#include <stdio.h>
int main(void)
{
int size, i;
printf("Enter the size of the arrays:
");
scanf("%d", &size);

int arr1[size];
printf("Enter the elements of the array:
");
for (i = 0; i < size; i++) {
    scanf_s("%d", arr1[size]);
}
printf("The current array is:
 %d", arr1[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

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 get random float 
C :: calculator in c 
C :: how to remove from a string c 
C :: printf c float 
C :: add 2 numbers in c 
C :: libdvd-pkg: `apt-get check` failed 
C :: dynamically create matrix c 
C :: remove first character from string c 
C :: const godot gdscript 
C :: c float to string 
C :: c assign pointer to struct 
C :: check prime number or not c 
C :: right side of div 
C :: what is system function in c 
C :: strong number in c 
C :: c printing char pointer 
C :: extract substring after certain character in flutter 
C :: format specifiers in c 
C :: fgets remove newline 
C :: how to reset all values of 2d vector to 0 
C :: c program to find the frequency of characters in a string 
C :: c check if character is a space 
C :: second largest element in an array 
C :: c calculate median 
C :: eliminare file in c 
C :: C fscanf ignore commas 
C :: how to join an array of strings c 
C :: ternary operator in c 
C :: loops questions on c 
C :: deleting a word with copy fuction c code 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =