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]);
}
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]);
}
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 %d\n",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\n",sum);
printf("Average is %d\n",avg);
printf("Max number is %d\n",max);
printf("Min number is %d\n",min);
return 0;
}
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("\nElements in array are: ");
for(i=0;i<n;i++)
{
printf("%d ", a[i]);
}
return 0;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us