Computer Science, asked by payalathawale67, 1 day ago

Write a c++ program to initialise with two elements and display with elements of array

Answers

Answered by aman2368
0

Answer:

// Array declaration by specifying size

int arr1[10];

// With recent C/C++ versions, we can also

// declare an array of user specified size

int n = 10;

int arr2[n];

// Array declaration by initializing elements

int arr[] = { 10, 20, 30, 40 }

// Compiler creates an array of size 4.

// above is same as "int arr[4] = {10, 20, 30, 40}"

// Array declaration by specifying size and initializing

// elements

int arr[6] = { 10, 20, 30, 40 }

// Compiler creates an array of size 6, initializes first

// 4 elements as specified by user and rest two elements as

// 0. above is same as "int arr[] = {10, 20, 30, 40, 0, 0}"

#include <stdio.h>

int main()

{

int arr[5];

arr[0] = 5;

arr[2] = -10;

arr[3 / 2] = 2; // this is same as arr[1] = 2

arr[3] = arr[0];

printf("%d %d %d %d", arr[0],

 arr[1], arr[2], arr[3]);

return 0;

}

Explanation:

in this any one is your answer

mark in brainlist

Similar questions