Now we will learn how to use the memory allocation. Here we will include<iomanip> .
/*Dynamic Memory Allocation*/
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int n;
cout<<"How many integers you have?";
cin>>n;
int *p=new int[n];
cout<<"Enter "<<n<<"Integers:";
for(int i=0;i<n;i++)
cin>>p[i];
for(int i=0;i<n;i++)
cout<<p[i]<<setw(5);//setw for space input
return 0;}
setw is used to give space for 5 decimal.
0 Comments had been done yet:
Post a Comment