// 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;
}
/**
* 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;
}
#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;
}
// 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]);
Code Example |
---|
C :: c find last element in array |
C :: c for |
C :: c check if character is an alphabet |
C :: fibonacci series in c |
C :: stack push |
C :: dynamic memory allocation c |
C :: Palindrome number in c program |
C :: convert string to int c |
C :: set the nth bit |
C :: c median of an array |
C :: how to return array of char in c |
C :: set all pins as output for loop |
C :: cifras de un numero en c |
C :: pointer arithmetic on Arrray in c |
C :: fread |
C :: prime numbers |
C :: scan c |
C :: %= in c |
C :: objects in oops |
C :: *= in c |
C :: c for result |
C :: allocating memory for 1Mb text file in C |
C :: print in c 11111 00000 11111 00000 11111 |
C :: C #if, #elif and #else Directive |
C :: how to make C program blink on screen |
C :: perl file handling |
C :: djb2 algorithm for C |
C :: how to delete data and add from file in c language |
C :: Integer Input/Output |
C :: [4,5,6] |