Recent

Comments

Follow us on Facebook

Monday 1 January 2018

take a single dimensional array set the default values to 0 or -1, take choice from the user if a inser values the values for the array, if b update the values and if c delete values from the array.

take a single dimensional array set the default values to 0 or -1, take choice from the user if a inser values  the values for the array, if b update the values and if c delete values from the array.
#include <iostream>
using namespace std;

int main()
{
int arr[5]={0},i,num;
char ss;
ii:

cout<<endl<<"OPTIONS: "<<endl;
cout<<endl<<"Press 'a' for inserting value in specific index."<<endl;
cout<<"Press 'b' for updating value in specific index."<<endl;
cout<<"Press 'c' for deleting value the specific index value."<<endl;

cout<<endl<<"Select option:";
cin>>ss;

cout<<endl;
switch(ss)
{
case 'a':
{

cout<<"enter index on which the number is to be add:";
cin>>i;
if(arr[i]==0)
{

cout<<"enter value to add: ";
cin>>num;
arr[i]=num;}

else
{
cout<<"selected index is not zero any more."<<endl<<endl;
}
}
break;

case 'b':
{

cout<<"enter index number which you want to update:";
cin>>i;
cout<<"enter updated value: ";
cin>>arr[i];
}
break;

case 'c':
{

cout<<"enter index number which you want to delet:";
cin>>i;
cout<<"enter 0 to delet value: ";
cin>>arr[i];

}
break;

default:
{
cout<<"Selected option is not correct...."<<endl;
cout<<"Choose the correct option from below menu:";
goto ii;
}
}
cout<<endl<<endl;
cout<<"Array elements are:";
for(int i=0; i<5; i++)
{
cout<<" "<<arr[i]<<"\t";
}
goto ii;
}


0 on: "take a single dimensional array set the default values to 0 or -1, take choice from the user if a inser values the values for the array, if b update the values and if c delete values from the array."

Write a program, that takes 16-Elements in Two-Dimensional-Array that has 4 rows & 4 columns, then display the diagonal of Matrix.

Write a program, that takes 16-Elements in Two-Dimensional-Array that has 4 rows & 4 columns, then display the diagonal of Matrix. ...

propeller ads

PropellerAds