Cube o Array Data structure by R4R Team

Array:
Array is the collection of different values having same data type.
-We have a integer Array that having all integer values.
-Character array is known as String.

Example-
Array is {3,2,4,1,5}
After cube the array, {27,8,64,1,125}

program-

#include < stdio.h>
int main()
{
int a[100],n,i,j,t;
printf("Enter number of elements\n");
scanf("%d",&n);
printf("Enter %d number in array\n",n);
//input in array
for(i=0;i< n;i++)
{
scanf("%d",&a[i]);
}
//Cube the numbers
for(i=0;i< n;i++)
{
a[i]=a[i]*a[i]*a[i];
}
//Now traverse
printf("After Cube \n");
for(i=0;i< n;i++)
{
printf("%d,",a[i]);
}
}


output-

Enter number of elements
5
Enter 5 number in array
1 2 3 4 5
After Cube
1,8,27,64,125,

-In this program, we take a input of the n number in the Array
-then traverse each item of array and cube then again store.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!