I was asked to do a program segment on these questions.
- That displays the last element of each row contained in Int A[20][50], Use While loop.
- That allocates an array D storing the square of integers from 1 to N.
- A while loop that determines the product of all odd integers from A to B exclusively.
1
While(a<20){
a++
cout<< A[a][50]<<"\n";
}
edit 1:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int a,n,m;
int A [20][50]={};
a=1;
cout<<"enter your number:"<<endl;
cin>>n;
cin>>m;
cout <<A [n][m] <<"\n";
while (a> 20){
cout << A [a][49]<<"\n";
}
system ("pause");
return 0;
edit 2:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int a,n,m;
int A [20][50]={};
a=1;
cout<<"enter your number:"<<endl;
cin>>n;
cin>>m;
cout <<A [n][m] <<"\n";
while (a < 20){
cout << A [a][49]<<"\n";
}
a++;
}
system ("pause");
return 0;
}
2
float num; float d[num];
cout<<"How many number do you want to enter to find there squure?"<<endl;
cin>>num;
for(int i; i<num; i++){
cin>>d[i];}
for(int i; i<num; i++) {
result[i]=d[i]*d[i];}
for(int i=0; i<num i++){
cout<<result[i];
edit 1
#include <iostream>
#include <string>
#include<iomanip>
using namespace std;
int main()
{
int b;
int x;
int A[]={};
int N;
int n;
cout <<"enter value for N:"<<endl;
cin>>N;
x=1;
n=N;
while (x<=N){
b =x*x;
A[n]=b;
x++ ;
}
cout <<A[n]<<"\t";
system ("pause");
return 0;
}
edit 2
#include <iostream>
#include <string>
using namespace std;
int main()
{
int x=1,b;
int N=5;
while (x<=N){
b=x*x;
cout<<b<<"\n";
x++;
}
system("pause");
return 0;
}
3
I have no idea on how i can do it :(
Are these codes correct? except number 3 cause I have really have no idea how to do it. can anyone correct these? Thank you very much :)
edit: I made a new answer to number 1 and made compilable :) edit: I edited my number 2 now. But can't seem to get it printed into an array. edit: Was able to make #2 work but I'm sure if It's the output being asked :s