0
nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
hey....

i just do it as simple like below, but what i am suppose to insert if i want it loop after wrong input in agency code and emotion code??
Code:
#include <iostream.h>

int main() 
{

    char  agency;
    int a ;

    cout<<"enter ur agency code:";
    cin>> agency;

    if(agency == 'x')
    {
        cout<<"enter ur emotion code:";
        cin>> a;
        if  ( (a ==  01)  ) {
        cout << "love" << endl;
        }
        else if ( a ==  02 ){ 
        cout << "angry" << endl;
        }
        else if ( a ==  03 ){ 
        cout << "sad" << endl;
        }
        else
        {
        cout << "u have no emotion!!!" << endl;
        }
    }
    else if(agency == 'y')
    {
            cout<<"enter ur emotion code:";
        cin>> a;
        if  ( (a ==  01)  ) {
        cout << "angry" << endl;
        }
        else if ( a ==  02 ){ 
        cout << "sad" << endl;
        }
        else if ( a ==  03 ){ 
        cout << "love" << endl;
        }
        else
        {
        cout << "u have no emotion!!!" << endl;
        }
    }
    else
    {
        cout << "Error!" << endl;
    }
  return 0;
}

Last edited by shabbir; 5Mar2010 at 08:30.. Reason: Code blocks
0
techgeek.in's Avatar, Join Date: Dec 2009
Skilled contributor
what u did is not a program my dear...u did the complete manipulation with the statement...let me check it in other compilers nd then i m getting back to u....or u can do one thing..u get the concept from the code i gave u nd try to implement from thr...
0
nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
ok.. i'll wait
0
techgeek.in's Avatar, Join Date: Dec 2009
Skilled contributor
my dear frnd this code is working fine in visual c++ and borland c++ as well..I have checked it several times..
Code:
# include<iostream.h>
# include<conio.h>

int expr_code[]={1,2,3};
char *exp[3]={"love","angry","sad"};

int main()
{
int choice,i,count=0;
int flag=1;
char *coded[3];
int j=0;

while(flag)
{
cout<<"press 1 if you are organisation A\n";
cout<<"press 2 if you are organisation B\n";
cout<<"press 3 if you want to exit\n";
cin>>choice;
switch(choice)
{
case 1:
cout<<"ready to send the codes to organisation B\n";
cout<<"actual data:- \n";

while(count<3)
{
cout<<expr_code[count];
cout<<exp[count];
cout<<"\n";
count++;
}


for(i=0;i<3;i++)
{

coded[j]=new char[10];
coded[j]=exp[(i+1)%3];
++j;

}
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<exp[i];
cout<<"\n";
}

cout<<"data sent:- \n";
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<coded[i];
cout<<"\n";
}



break;

case 2:
cout<<"ready to receive data from organisatin A";
cout<<"data received:-  \n";
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<coded[i];
cout<<"\n";
}
     j=0;
 for(i=0;i<=3;++i)
 {
 exp[j]=new char[10];
exp[j]=coded[(i+2)%3];
j++;
  }
cout<<"actual data :  \n";
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<exp[i];
cout<<"\n";
}

break;
case 3:
flag=0;
break;
}
}
getch();
return 0;
}
0
nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
hai.. unfortunately when i execute it become as per attachment..
[IMG]file:///C:/DOCUME%7E1/TRAINI%7E1.ICT/LOCALS%7E1/Temp/moz-screenshot-2.png[/IMG]


[IMG]file:///C:/DOCUME%7E1/TRAINI%7E1.ICT/LOCALS%7E1/Temp/moz-screenshot.png[/IMG][IMG]file:///C:/DOCUME%7E1/TRAINI%7E1.ICT/LOCALS%7E1/Temp/moz-screenshot-1.png[/IMG]
Attached Images
File Type: jpg error.jpg (18.6 KB, 4 views)
0
techgeek.in's Avatar, Join Date: Dec 2009
Skilled contributor
Quote:
Originally Posted by nonie azlan View Post
hai.. unfortunately when i execute it become as per attachment..
[IMG]file:///C:/DOCUME%7E1/TRAINI%7E1.ICT/LOCALS%7E1/Temp/moz-screenshot-2.png[/IMG]


[IMG]file:///C:/DOCUME%7E1/TRAINI%7E1.ICT/LOCALS%7E1/Temp/moz-screenshot.png[/IMG][IMG]file:///C:/DOCUME%7E1/TRAINI%7E1.ICT/LOCALS%7E1/Temp/moz-screenshot-1.png[/IMG]
sorry..i m not understanding why r u getting errors?? i have no clue..
0
virxen's Avatar, Join Date: Nov 2009
Pro contributor
Quote:
Originally Posted by techgeek.in View Post
sorry..i m not understanding why r u getting errors?? i have no clue..
i compiled your code in visual c++ 6.0, and it compiles and runs with no errors


nonie azlan post your code here.maybe you changed or forgot something in the code.
0
nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
hai.. here as per request...

Code:
# include<iostream.h>
# include<conio.h>

int expr_code[]={1,2,3};
char *exp[3]={"love","angry","sad"};

int main()
{
int choice,i,count=0;
int flag=1;
char *coded[3];
int j=0;

while(flag)
{
cout<<"press 1 if you are organisation A\n";
cout<<"press 2 if you are organisation B\n";
cout<<"press 3 if you want to exit\n";
cin>>choice;
switch(choice)
{
case 1:
cout<<"ready to send the codes to organisation B\n";
cout<<"actual data:- \n";

while(count<3)
{
cout<<expr_code[count];
cout<<exp[count];
cout<<"\n";
count++;
}


for(i=0;i<3;i++)
{

coded[j]=new char[10];
coded[j]=exp[(i+1)%3];
++j;

}
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<exp[i];
cout<<"\n";
}

cout<<"data sent:- \n";
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<coded[i];
cout<<"\n";
}



break;

case 2:
cout<<"ready to receive data from organisatin A";
cout<<"data received:-  \n";
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<coded[i];
cout<<"\n";
}
     j=0;
 for(i=0;i<=3;++i)
 {
 exp[j]=new char[10];
exp[j]=coded[(i+2)%3];
j++;
  }
cout<<"actual data :  \n";
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<exp[i];
cout<<"\n";
}

break;
case 3:
flag=0;
break;
}
}
getch();
return 0;
}

Last edited by shabbir; 9Mar2010 at 10:02.. Reason: Code blocks
0
nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
hai...

so easy n happy to say that today i can run that program smoothly... wow! i need to work hard to understand your program.. could u help me when i need u to explain if i have any question?