#include<iostream>
using namespace std;
void main()
{
int i,N,Loc,New;
char a[10];
int array[20];
cout<<"Enter the size of Array Max20 :";
cin>>N;
if(N<=20)
{
array[N];
cout<<"Enter the Element of Array";
for(i=0;i<N;i++)
{
cout<<"\nEnter the element "<<i+1<<" : ";
cin>>array[i];
}
cout<<"You want to enter new element \n";
cin>>a;
if(a=="yes"|| "Yes")
{
cout<<"\nEnter the element which you want to insert";
cin>>New;
cout<<"Enter the location to insert the element";
cin>>Loc;
int y=Loc-1;
for(i=0;i<N;i++)
{
if(y==i){
array[i]=New;
break;
}
}
cout<<"\nNew Array";
for(i=0;i<N;i++)
{
cout<<"["<<array[i]<<"]";
}
}
else{
cout<<"thank you";
}
}
else{
cout<<"Size is to large";
}
}
}
Details About problem :
The if/else block (else{cout<<"thank you";}
)is not working.
Every time I run the code
- I enter the size of array.
- I enter the elements of it.
- I get two choices yes or no.
- problem arising here if I enter yes if will work but if I enter the no again only if block work.
I tried but I not find any answer but I think used logical or in wrong way in if block...
Please help me.
Thank you