Write a program that finds and displays square and cubes of each array element. Given array numbers are : 10,15,-17,24,12
source file name: Arrsqcube.C
#include<stdio.h>
int main()
{
int A[]={10,15,-17,24,12};
int i,sq,c;
//clrscr();
printf("\nArray numbers are: ");
for(i=0;i<5;i++)
{
printf(" %d ",A[i]);
}
printf("\n square and cube of each array numbers: ");
for(i=0;i<5;i++)
{
sq=A[i]*A[i];
c=A[i]*A[i]*A[i];
printf("\n %d %d",sq,c);
}
//getch();
return 0;
}
output:
0 Comments
Post a Comment