int size=5;
int array[size]; // array of size=5;
for(i=0;i<size;i++){
scanf("%d",&array[i]);
}
// 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;
}
#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;
}
int i, arr[10];
for(i = 0; i < sizeof(arr) / sizeof(struct i); i++)
{
cin >> (arr[i].data);
}
// 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]);