cout<<num<<" is the first number, the next "<<consecnum<<" consecutive numbers are "<<num2[1]<<endl;
Full code
#include <iostream>
using namespace std;
int main()
{
int num, consecnum, sum, i, num3, j;
cout<<"Enter a starting number"<<endl;
cin>>num;
cout<<"Enter a consecutive number."<<endl;
cin>>consecnum;
int num2[consecnum];
sum = num + consecnum;
num2[0] = num;
num3 = num;
int oddarray[j];
int x=1;
int y;
for(i=1; num3<sum; i++)
{
num2[i]=num+i;
cout<<num2[i]<<endl;
num3++;
if(num2[i] % 2 != 0)
{
oddarray[x] = num2[i];
x++;
}
}
cout<<" "<<endl;
cout<<num<<" is the first number, the next "<<consecnum<<" consecutive numbers are "<<num2[1]<<endl;
for(y=1; y<consecnum; y++)
{
cout<<oddarray[y]<<endl;
}
system("pause");
return 0;
}

New Topic/Question
Reply




MultiQuote





|