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

Program to input and print array elements in c

/**
 * C program to read and print elements in an array
 */

#include <stdio.h>
#define MAX_SIZE 1000 // Maximum array size

int main()
{
    int arr[MAX_SIZE]; // Declare an array of MAX_SIZE
    int i, N;

    /* Input array size */
    printf("Enter size of array: ");
    scanf("%d", &N);

    /* Input elements in array */
    printf("Enter %d elements in the array : ", N);
    for(i=0; i<N; i++)
    {
        scanf("%d", &arr[i]);
    }


    /*
     * Print all elements of array
     */
    printf("
Elements in array are: ");
    for(i=0; i<N; i++)
    {
        printf("%d, ", arr[i]);
    }

    return 0;
}
Comment

printing out an array in c from user input

#include <stdio.h>
 
int main()
{
    int a[1000],i,n;  
 
     printf("Enter size of array: ");
    scanf("%d",&n);
 
     printf("Enter %d elements in the array : ", n);
    for(i=0;i<n;i++)
    {
        scanf("%d", &a[i]);
    }
 
    printf("
Elements in array are: ");
    for(i=0;i<n;i++)
 
    {
        printf("%d  ", a[i]);
    }
 
    return 0;
}
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 float and double Output 
C :: static variable c 
C :: logical operators 
C :: what is the last character of a string in c 
C :: stack pop 
C :: Regex to match any character being repeated more than 10 times 
C :: what is %d in C 
C :: convert python to c 
C :: linux_reboot_magic2 
C :: allintext:christie kiser filetype:log 
C :: Print mark-sheet of students 
C :: Highest integer among the four inputs in c 
C :: how to do Employing defensive code in the UI to ensure that the current frame is the most top level window 
C :: how can i learn c game development 
C :: divide a linked list into three parts based on their position mod 3. 
C :: %s and string pointer 
C :: e sharm card jobkhozo.com 
C :: cmake boilerplate for visual studio c++ project 
C :: python project script run 
C :: gtk widget change window title 
C :: google sheets transpose new line to table 
C :: Integer Input/Output 
C :: python to c converter online free 
C :: why return 0 is written at the code end? 
C :: payement des véhicules a la sortie de station de langue c 
C :: not repeated serial number in c 
C :: C what does /= mean 
C :: calendar in c 
Dart :: flutter textformfield hide underline 
Dart :: flutter appbar text color 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =