In c++ Write a program that creates a dynamically allocated array to store students’ grades. The user should be able to decide the size of the array during run time. Write code to fill this array from the keyboard and then print out the values of your array,
#source code:
#include <iostream>
#include <new>
using namespace std;
int main(){
int i,num,*sub;
cout<<"Enter Number of Grades:"<<endl;
cin>>num;
sub=new (nothrow) int[i];
if(sub==nullptr){
cout<<"The memory can'b be allocated"<<endl;
}else{
for(i=0;i<num;i++){
cout<<"Enter grade "<<i+1<<":";
cin>>sub[i];
}
cout<<"You Enter grades are:";
for(int i=0;i<num;i++){
cout<<sub[i]<<" ";
}cout<<endl;
}
return 0;
}
#output:
#if you have any doubt or more information needed comment below...i will respond as possible as soon..thanks...
Get Answers For Free
Most questions answered within 1 hours.