A program to initialize a 1-D array with the next 5 multiples of a number entered by the user.

 

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int a[5],i,n;

cout<<"Enter a number: ";
cin>>n;

for(i=1;i<=5;i++)
a[i]=i*n;

for(i=1;i<=5;i++)
cout<<a[i]<<" ";

getch();
}

 

< Back