Monday, 21 September 2015

Dynamic array source code, c++, source code,

Dynamic array source code, c++,
// dynamicarray.cpp : Defines the entry point for the console application.
//












#include "stdafx.h"
#include <iostream.h>
#include <process.h>
#include <cctype>

typedef int* IntPtr;
typedef int* intptr;

void input(IntPtr array,intptr array2,int &used)
{
cout<<"enter number = ";
cin>>array2[used];
cin>>array[used];
used++;
}
void addat(IntPtr p,int index,int used,int number)
{
IntPtr temp=0;
temp=p;
int j=0;
cout<<"TEmp = ";
for (int i=0;i<used;i++)
{
cout<<temp[i]<<",";
}
for (i=0,j=0;j<used;i++)
{
if (index==i && index==j)
{
p[i]=number;


else
{
p[i]=temp[j];
j++;
}
}
used++;
}

void main(int argc, char* argv[])
{
IntPtr p,p2;
char ans;
int used=5;
p=new int;
p2=new int;
for(int i=0;i<used;i++)
{
p[i]=i+1;
}

do{
system("cls");



cout<<"_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"<<endl;
    cout<<"==+===+===+==+===+===+===+===+===+===+==+==+==+===+===+===+===+===+===+==+==+"<<endl;
cout<<"\t"<<"\t"<<"+--> "<<" PRESS 'A' TO ADD"<<"\t"<<"\t"<<"    +"<<endl;
cout<<"==+===+===+==+===+===+===+===+===+===+==++==+===+===+===+===+===+===+==+====+"<<endl;
    cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<endl;
cout<<"Array = {";
for(int i=0;i<used;i++)
{

}
switch(toupper(ans))

{
case 'A':
{
input(p,p2,used);
for(int i=0;i<used;i++)
{
  p2=p;
}

break;

}
default:
{
cout<<"\t"<<"\t"<<"Invalid choice"<<endl;

}
cout<<"\t"<<"\t"<<"Execute again Y/N";
cin>>ans;
}

}while(ans=='y' || ans=='Y');
}



Dear Readers if you have any query/question feel free to ask me via comment box given below. Also Follow us on social media site and share that post with your friends. - See more at: http://onlinecomputercafe.blogspot.com 

useful tutorial keep it up...
EmoticonEmoticon

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:o
:>)
(o)
:p
:-?
(p)
:-s
8-)
:-t
:-b
b-(
(y)
x-)
(h)

LinkWithin