Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,613 members, 7,816,518 topics. Date: Friday, 03 May 2024 at 12:31 PM

C++ Beginner Discussion Room: Drop Your Codes - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / C++ Beginner Discussion Room: Drop Your Codes (11652 Views)

I Want To Hire A Beginner Who Is Willing To Learn New Skills / Special Codes To Format Text On Nairaland / Should A Beginner Learn 2 Programming Languages At Once? (2) (3) (4)

(1) (2) (3) (4) (5) (Reply) (Go Down)

Re: C++ Beginner Discussion Room: Drop Your Codes by raynold(m): 8:49am On Dec 11, 2013
adelolaa: /********************************

ASSIGNMENT: write a program that declares a class called "employee" with these data members: itsAge, itsYearsOfService, itsSalary.


HOD: Teach ur self c++ in 21days

STUDENT: Xarmzon.

********************-***********/
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <ctime>

using namespace std;

class employee
{
public:
int getAge(){
return itsAge;
}
void setAge(int age){
itsAge = age;
}

int getYearsOfService(){
return itsYearsOfService;
}
void setYearsOfService(int yearsOfS){
itsYearsOfService = yearsOfS;
}

int getSalary(){
return itsSalary;
}
void setSalary(int salary){
itsSalary = salary;
}

private:

int itsAge;
int itsYearsOfService;
int itsSalary;


};

int main()
{
string name;
employee age;
age.setAge(20);
employee year;
year.setYearsOfService(6);

cout << "Enter your name: ";
getline (cin, name);

cout << name << " is "<< age.getAge() << " years of age and " << year.getYearsOfService() << " years of age in service." <<endl;


}
nice program but how do u go about a program that accept age and like increases every year( if possible)..
Re: C++ Beginner Discussion Room: Drop Your Codes by raynold(m): 9:00am On Dec 11, 2013
adelolaa:

Q3: Write a small calculator that takes as input one of the four arithmetic operations, the two argument to those operation, and then print out the result.



wrote a C program for this.. I'll try it in c++
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 9:47am On Dec 11, 2013
raynold: nice program but how do u go about a program that accept age and like increases every year( if possible)..


don't know about that one!!! am still learning
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 10:00am On Dec 11, 2013
/***********---******************

Assignments: (if, else if and else statement)

HOD: ALEX ALLAIN

STUDENT: XARMZON

COURSE: JUMPING INTO C++

Q1: Ask the user for two user's ages, and indicate who is older, behave differently if both are over 100.

Q2: Implement a simple "password" system that takes a password in the form of a number. Make it so that either of the two numbers are valid, but use only one if statement to do the check.

Q3: Write a small calculator that takes as input one of the four arithmetic operations, the two argument to those operation, and then print out the result.

Q4: Expand the password checking program from earlier in this chapter and make it multiple usernames. Each with their own password and provide the ability to prompt user's again if the first attempt failed. Think about how easy(or hard) it is to do this for a lot of usernames and password.

SOLUTION TO Q2

******************************/


#include <iostream>

#include <string>

using namespace std;


int main()
{

int password;

cout << "Enter your password: " ;
cin >> password;

if (password == 1230 || password == 3028)
{
cout << "Login successful!";
}
else
{
cout << "Access denied!";
}



}


Q2 solution
Re: C++ Beginner Discussion Room: Drop Your Codes by raynold(m): 7:06pm On Dec 11, 2013
Q3: Write a small calculator that
takes as input one of the four
arithmetic operations, the two
argument to those operation, and
then print out the result.
answer below..

please need you guys help
note : this C program allows user to chose from three(3) different arithmetic operators to solve a problem..
now the problem is the " invalid choice" keeps appearing after the program solves the problem.(program runs)
YOU CAN RUN THE PROGRAM SO YOU'LL SEE THE PROBLEM..


#include<stdio.h>
#include<stdlib.h>
main()
{
int a, b, c;
int choice;
printf ("\t\t\t choose operation\n" );
printf ("\t\t\t -1 addition\n \t\t\t -2 substraction\n \t\t\t -3 multipication\n" );
printf ("\t\t\t -4 exit\n " );
scanf ("%d",&choice);
if (choice == 1)
{
printf ("enter first value :" );
scanf ("%d", &a);
printf ("enter second value :" );
scanf ("%d",&b);
c = a+b;
printf (" addition is %d",c);
}
if (choice == 2)
{
printf ("enter first value :" );
scanf ("%d",&a);
printf ("enter second value :" );
scanf ("%d",&b);
c = a - b;
printf (" the subtraction is %d",c );
}
if (choice == 3)
{
printf ("enter first value :" );
scanf ("%d",&a);
printf ("enter second value :" );
scanf ("%d",&b);
c = a * b;
printf (" the multiplication is %d\n", c );
}
if (choice == 4)
{
printf ("\t\t\t thanks for using mini calcultor bye" );
}
else
{
printf ("\t\t\t invalid choice" );
}
}
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 7:32pm On Dec 11, 2013
raynold: Q3: Write a small calculator that
takes as input one of the four
arithmetic operations, the two
argument to those operation, and
then print out the result.
answer below..

please need you guys help
note : this C program allows user to chose from three(3) different arithmetic operators to solve a problem..
now the problem is the " invalid choice" keeps appearing after the program solves the problem.(program runs)
YOU CAN RUN THE PROGRAM SO YOU'LL SEE THE PROBLEM..


#include<stdio.h>
#include<stdlib.h>
main()
{
int a, b, c;
int choice;
printf ("\t\t\t choose operation\n" );
printf ("\t\t\t -1 addition\n \t\t\t -2 substraction\n \t\t\t -3 multipication\n" );
printf ("\t\t\t -4 exit\n " );
scanf ("%d",&choice);
if (choice == 1)
{
printf ("enter first value :" );
scanf ("%d", &a);
printf ("enter second value :" );
scanf ("%d",&b);
c = a+b;
printf (" addition is %d",c);
}
if (choice == 2)
{
printf ("enter first value :" );
scanf ("%d",&a);
printf ("enter second value :" );
scanf ("%d",&b);
c = a - b;
printf (" the subtraction is %d",c );
}
if (choice == 3)
{
printf ("enter first value :" );
scanf ("%d",&a);
printf ("enter second value :" );
scanf ("%d",&b);
c = a * b;
printf (" the multiplication is %d\n", c );
}
if (choice == 4)
{
printf ("\t\t\t thanks for using mini calcultor bye" );
}
else
{
printf ("\t\t\t invalid choice" );
}
}




use switch instead of if. i don't knw anything abt c though. I prefer c++
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 7:32pm On Dec 11, 2013
/***********---******************

Assignments: (if, else if and else statement)

HOD: ALEX ALLAIN

STUDENT: XARMZON

COURSE: JUMPING INTO C++

Q1: Ask the user for two user's ages, and indicate who is older, behave differently if both are over 100.

Q2: Implement a simple "password" system that takes a password in the form of a number. Make it so that either of the two numbers are valid, but use only one if statement to do the check.

Q3: Write a small calculator that takes as input one of the four arithmetic operations, the two argument to those operation, and then print out the result.

Q4: Expand the password checking program from earlier in this chapter and make it multiple usernames. Each with their own password and provide the ability to prompt user's again if the first attempt failed. Think about how easy(or hard) it is to do this for a lot of usernames and password.

SOLUTION TO Q3

******************************/


#include <iostream>

#include <string>

using namespace std;


int main()
{

double firstNum = 0; // declare varable
double secondNum = 0; // declare varable

cout << "Enter the numerator and denominator: " << endl;

cout << "Numerator: "; // ask user for numerator
cin >> firstNum; // assign numerator to first number

cout << "Denominator: " ; // ask user fot denominator
cin >> secondNum; // assign denominator to second number


cout << firstNum << " + " << secondNum << " = " << firstNum + secondNum << endl; // print out addition of first number and second number

cout << firstNum << " * " << secondNum << " = " << firstNum * secondNum << endl; // print out multiplication of first number and the second number

cout << firstNum << " - " << secondNum << " = " << firstNum - secondNum << endl; // print out subtraction of first number and the second number

cout << firstNum << " / " << secondNum << " = " << firstNum / secondNum << endl; // print out division of first number and the second number

cout << "Thank You!!!!!" << endl; // print out thank you!!!!

// end of the question two(3) solution. by xarmzon.

}
Re: C++ Beginner Discussion Room: Drop Your Codes by wisemania(m): 10:11pm On Dec 11, 2013
//soln to Q1 in c, reads in two age values and decribes the relationship existing between them

#include <stdio.h>
int main()
{
int age1, age2; //age val decleration

printf("Enter first age value: " );
scanf("%d", &age1);
printf("Enter second age value: " );
scanf("%d", &age2);

if (age1 > age2)
printf("%d is of a greater age than %d\n", age1, age2);

if (age2 > age1)
printf("%d is of a greater age than %d\n", age2, age1),

if (age1 == age2)
printf("Both age inputs are of the same value\n" );
return 0;
}

1 Like

Re: C++ Beginner Discussion Room: Drop Your Codes by wisemania(m): 10:46pm On Dec 11, 2013
// soln in C to Q 3-- the mini calculator ,using the if else loop

#include <stdio.h>
int main()
{
float x, y; //values read
int a, b, c, d, opr;// decleration
a = 1; //rep addition
b = 2; //rep subtraction
c = 3; // rep multiplication
d = 4; //rep division

printf("Enter two digits please : " );
scanf("%f %f", &x, &y) ;
printf("Enter operational value please(1 for add, 2 for subtr, 3 for mult, and 4 for div) : " ) ;
scanf("%d", &opr) ;

if (opr == a)
printf("The sum(%f + %f) is %.3f\n", x, y, (x + y)) ;

else if (opr == b)
printf("The difference(%f - %f) is %.3f\n", x, y, (x - y)) ;

else if (opr == c)
printf("The product(%f * %f) is
%.3f\n", x, y, (x * y)) ;

else if (opr == d)
printf("The quotient(%f / %f) is
%.3f\n", x, y, (x / y)) ;

return 0;
}
Re: C++ Beginner Discussion Room: Drop Your Codes by wisemania(m): 11:16pm On Dec 11, 2013
//soln in C to Q2, activation code programusing just an "if" stat

#include <stdio.h>
int main()
{
int pswrd1, pswrd2, pass1, pass2;

pswrd1 = 1759;//my access code
pswrd2 = 2020; //my access code

printf("Enter the first activation code please: " ); //code prompt
scanf("%d", &pass1);//read input

printf("Enter the second activation code please; " );//2nd code prompt
scanf("%d", &pass2);//read input

if ((pass1 == pswrd1 || pass1 ==
pswrd2) &&
(pass2 == pswrd1 || pass2 ==
pswrd2)) //comparism

// out put if true
printf("Acsess granted!\n" );

else //output if false
printf("Access denied!\n" );

return 0; //program termination
}
//ill try n paste d c++ version 2moro...gudnyt ya'll......

1 Like

Re: C++ Beginner Discussion Room: Drop Your Codes by wisemania(m): 11:26pm On Dec 11, 2013
@raynold:
d reason y ur code isnt runnin is coz u used d "true" and "false" bool val of c/cpp to exterblish a relationship btw d tests vals...nid i remind u dat in c/cpp/java etc....0 is equivalent to false, while any non-zero value is equivalent to true...hence ur program wen on vacation....meaning, "if (x == 0)" tells d compiler to check if "x" is false, while "if (x == 1 or any oda non-zero val)" telss d compiler to report "true" if true...thanks...

@OP:
pls du d c-newbies a favour by editing d title of this tred to suit both C and C++ newbies..coz i wudnt wana create a new tred for C.....and thanks 4d c4droid link..it ran my c codes perfectly,bt wen i tried running cpp it requested i download a gcc compiler dou....al d xame i appreciate d link...u du wel
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 7:09am On Dec 12, 2013
wisemania: //soln to Q1 in c, reads in two age values and decribes the relationship existing between them

#include <stdio.h>
int main()
{
int age1, age2; //age val decleration

printf("Enter first age value: " );
scanf("%d", &age1);
printf("Enter second age value: " );
scanf("%d", &age2);

if (age1 > age2)
printf("%d is of a greater age than %d\n", age1, age2);

if (age2 > age1)
printf("%d is of a greater age than %d\n", age2, age1),

if (age1 == age2)
printf("Both age inputs are of the same value\n" );
return 0;
}


c++ is straight forward than c. I love c++. nice work
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 7:10am On Dec 12, 2013
wisemania: //soln in C to Q2, activation code programusing just an "if" stat

#include <stdio.h>
int main()
{
int pswrd1, pswrd2, pass1, pass2;

pswrd1 = 1759;//my access code
pswrd2 = 2020; //my access code

printf("Enter the first activation code please: " ); //code prompt
scanf("%d", &pass1);//read input

printf("Enter the second activation code please; " );//2nd code prompt
scanf("%d", &pass2);//read input

if ((pass1 == pswrd1 || pass1 ==
pswrd2) &&
(pass2 == pswrd1 || pass2 ==
pswrd2)) //comparism

// out put if true
printf("Acsess granted!\n" );

else //output if false
printf("Access denied!\n" );

return 0; //program termination
}
//ill try n paste d c++ version 2moro...gudnyt ya'll......



nice one
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 7:13am On Dec 12, 2013
wisemania:

@OP:
pls du d c-newbies a favour by editing d title of this tred to suit both C and C++ newbies..coz i wudnt wana create a new tred for C.....and thanks 4d c4droid link..it ran my c codes perfectly,bt wen i tried running cpp it requested i download a gcc compiler dou....al d xame i appreciate d link...u du wel


yes!!! u must download GCC for it to work!!
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 7:15am On Dec 12, 2013
/***********---******************

Assignments: (if, else if and else statement)

HOD: ALEX ALLAIN

STUDENT: XARMZON

COURSE: JUMPING INTO C++

Q1: Ask the user for two user's ages, and indicate who is older, behave differently if both are over 100.

Q2: Implement a simple "password" system that takes a password in the form of a number. Make it so that either of the two numbers are valid, but use only one if statement to do the check.

Q3: Write a small calculator that takes as input one of the four arithmetic operations, the two argument to those operation, and then print out the result.

Q4: Expand the password checking program from earlier in this chapter and make it multiple usernames. Each with their own password and provide the ability to prompt user's again if the first attempt failed. Think about how easy(or hard) it is to do this for a lot of usernames and password.

SOLUTION TO Q4

******************************/


#include <iostream>

#include <string>

using namespace std;


int main()
{

string username = " ";
string password = " ";

cout << "Enter your usename and password:" << endl;

cout << "Username: " ;
cin >> username;
cout << "Password: " ;
cin >> password;

if((username == "jeff" && password == "12hb" ) || (username == "judinho" && password == "jboy1" ) || (username == "andy" && password == "xarm" ) || (username == "sara" && password == "sarandy" ) || (username == "air" && password == "vaans1" ) || (username == "zesus" && password == "zenal" ) || (username == "sete" && password == "admin1" ) || (username == "wilson" && password == "bigh1" ) || (username == "doglaries" && password == "dogas" ) || (username == "onome" && password == "9087" ) || (username == "funky" && password == "1187" ))

{
cout << "Login successful!!!" << endl;
}
else
{
cout << "Access denied!!" << endl;

int confirm = 0;

cout << "press 1 to re-enter or -1 to quit" << endl;
cin >> confirm;

if (confirm == 1)
{
cout << "Username: " ;
cin >> username;
cout << "Password: " ;
cin >> password;

if((username == "jeff" && password == "12hb" ) || (username == "judinho" && password == "jboy1" ) || (username == "andy" && password == "xarm" ) || (username == "sara" && password == "sarandy" ) || (username == "air" && password == "vaans1" ) || (username == "zesus" && password == "zenal" ) || (username == "sete" && password == "admin1" ) || (username == "wilson" && password == "bigh1" ) || (username == "doglaries" && password == "dogas" ) || (username == "onome" && password == "9087" ) || (username == "funky" && password == "1187" ))

{
cout << "Login successful!!!" << endl;
}
else
{
cout << "Access denied!!" << endl;


cout << " Alert!!!! fraud!!!!!" << endl;
}
}
else if (confirm == -1)
{
cout << "Program terminating! thank you" << endl;

}

}

// solution to quetion four by xarm lee
}

end of chapter four questions
Re: C++ Beginner Discussion Room: Drop Your Codes by wisemania(m): 4:14pm On Dec 12, 2013
^^thanks bro....uve don a gr8 job...dats y i love cpp to c wen it comes to complexity management..id av loved to translate it in2 c,bt my username and passwrd wud av 2b in characters(excluding numbers) only,i.e i wont be previleged to input a paswrd of dis sort : "bigh1" coz der wud be an error...
I avnt got 2d string aspect of inputin numbers in to strings 4now,bt as tym goes on,ill wrk smfin out..so ill let Q4 pass 4now...

1 Like

Re: C++ Beginner Discussion Room: Drop Your Codes by Nobody: 4:38pm On Dec 12, 2013
qn 4 can also be answered with the use of a while statement that will loop continuously till the user enters the right password!

But in ur solution yu used if statement for that! Which also works tho but limits the amount of trials by the user

1 Like

Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 7:22pm On Dec 12, 2013
veektorh: qn 4 can also be answered with the use of a while statement that will loop continuously till the user enters the right password!

But in ur solution yu used if statement for that! Which also works tho but limits the amount of trials by the user


thanks!! I will fix that
Re: C++ Beginner Discussion Room: Drop Your Codes by Olyboy16(m): 1:08am On Dec 13, 2013
wisemania:
bro how du u make ur programs interactive using d c4droid compiler...
Coz i installed it yesterrday ran some codes on it,it ran perfectly well....but wen i tried makin it interactive using the input function ("scanf" for C-program and "cin" for c++ programs), the compiiler just ignored it like it waz neva there in my codes....d codes i ran could only print characters,i'd like u 2 explain in plain eng how u get 2 make ur own codes interactive using d "cin" command to read inputs from a user....*waiting patiently*

it may not actualy be a technical compiler defect, try adding cin.ignore(); before your I/O statements to overload it. It should work then
Re: C++ Beginner Discussion Room: Drop Your Codes by Olyboy16(m): 1:13am On Dec 13, 2013
adelolaa: /***********---******************

Assignments: (if, else if and else statement)

HOD: ALEX ALLAIN

STUDENT: XARMZON

COURSE: JUMPING INTO C++

Q1: Ask the user for two user's ages, and indicate who is older, behave differently if both are over 100.

Q2: Implement a simple "password" system that takes a password in the form of a number. Make it so that either of the two numbers are valid, but use only one if statement to do the check.

Q3: Write a small calculator that takes as input one of the four arithmetic operations, the two argument to those operation, and then print out the result.

Q4: Expand the password checking program from earlier in this chapter and make it multiple usernames. Each with their own password and provide the ability to prompt user's again if the first attempt failed. Think about how easy(or hard) it is to do this for a lot of usernames and password.

SOLUTION TO Q4

******************************/


#include <iostream>

#include <string>

using namespace std;


int main()
{

string username = " ";
string password = " ";

cout << "Enter your usename and password:" << endl;

cout << "Username: " ;
cin >> username;
cout << "Password: " ;
cin >> password;

if((username == "jeff" && password == "12hb" ) || (username == "judinho" && password == "jboy1" ) || (username == "andy" && password == "xarm" ) || (username == "sara" && password == "sarandy" ) || (username == "air" && password == "vaans1" ) || (username == "zesus" && password == "zenal" ) || (username == "sete" && password == "admin1" ) || (username == "wilson" && password == "bigh1" ) || (username == "doglaries" && password == "dogas" ) || (username == "onome" && password == "9087" ) || (username == "funky" && password == "1187" ))

{
cout << "Login successful!!!" << endl;
}
else
{
cout << "Access denied!!" << endl;

int confirm = 0;

cout << "press 1 to re-enter or -1 to quit" << endl;
cin >> confirm;

if (confirm == 1)
{
cout << "Username: " ;
cin >> username;
cout << "Password: " ;
cin >> password;

if((username == "jeff" && password == "12hb" ) || (username == "judinho" && password == "jboy1" ) || (username == "andy" && password == "xarm" ) || (username == "sara" && password == "sarandy" ) || (username == "air" && password == "vaans1" ) || (username == "zesus" && password == "zenal" ) || (username == "sete" && password == "admin1" ) || (username == "wilson" && password == "bigh1" ) || (username == "doglaries" && password == "dogas" ) || (username == "onome" && password == "9087" ) || (username == "funky" && password == "1187" ))

{
cout << "Login successful!!!" << endl;
}
else
{
cout << "Access denied!!" << endl;


cout << " Alert!!!! fraud!!!!!" << endl;
}
}
else if (confirm == -1)
{
cout << "Program terminating! thank you" << endl;

}

}

// solution to quetion four by xarm lee
}

end of chapter four questions

i always tell coders to try and get used to the getline() function when inputing string...please opitimize your codes to use getline() to get only your desired number of string chars, dis would save you from buffer overflow errors
Re: C++ Beginner Discussion Room: Drop Your Codes by wisemania(m): 1:23am On Dec 13, 2013
Olyboy16:

i always tell coders to try and get used to the getline() function when inputing string...please opitimize your codes to use getline() to get only your desired number of string chars, dis would save you from buffer overflow errors
we're still learning bro.....with time we'll know this things...do well to solve Q4 for us in C...thanks
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 8:48am On Dec 13, 2013
Olyboy16:

it may not actualy be a technical compiler defect, try adding cin.ignore(); before your I/O statements to overload it. It should work then

mine is working without that
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 8:49am On Dec 13, 2013
Olyboy16:

i always tell coders to try and get used to the getline() function when inputing string...please opitimize your codes to use getline() to get only your desired number of string chars, dis would save you from buffer overflow errors

thanks master. I will put that in mind
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 8:51am On Dec 13, 2013
am proceeding to chapter five tomorrow
Re: C++ Beginner Discussion Room: Drop Your Codes by wisemania(m): 12:42pm On Dec 13, 2013
adelolaa: am proceeding to chapter five tomorrow
bro what's your purpose for learning c++?......make i kw, weda make i 4get about c grin
Re: C++ Beginner Discussion Room: Drop Your Codes by Olyboy16(m): 4:05pm On Dec 13, 2013
adelolaa:

mine is working without that

you cant judge by that since compilers behave differently u knw...
Re: C++ Beginner Discussion Room: Drop Your Codes by Olyboy16(m): 4:10pm On Dec 13, 2013
wisemania:
we're still learning bro.....with time we'll know this things...do well to solve Q4 for us in C...thanks

u knw, i realy wish i could participate more by posting answers, bt NEPA has been doing their thingy for 2 days nw...so i'm on mobile..wil stil contribute d little i can though.. Nice work guys @adelolaa
Re: C++ Beginner Discussion Room: Drop Your Codes by Olyboy16(m): 4:14pm On Dec 13, 2013
wisemania:
bro what's your purpose for learning c++?......make i kw, weda make i 4get about c grin

one big advice bro: dont 4get any language u learn, you should rather improve on the ones you find easier...knwing multiple languages wil make you feel and think lyk a guru...
Re: C++ Beginner Discussion Room: Drop Your Codes by adelolaa(m): 7:08pm On Dec 13, 2013
wisemania:
bro what's your purpose for learning c++?......make i kw, weda make i 4get about c grin

Lol. programming is my dream. so I choose c++
Re: C++ Beginner Discussion Room: Drop Your Codes by raynold(m): 12:49pm On Dec 14, 2013
wrote this program in c and its working perfectly, just wrote this now in c++..

#include<iostream>

using namespace std;
int main()
{
int a, b, c, num;
int choice;
cout<< "\t\t\t welcom choose your operation\n";
for ( num = 1; num <= 7; num++)
{
cout<< "\t\t\t -1 addition\n \t\t\t -2 substraction\n \t\t\t -3 multipication\n";
cout<< "\t\t\t -4 exit\n ";
cin>> choice;
if (choice == 1)
{
cout<< "enter first value :";
cin>> a;
cout<< "enter second value :";
cin>> b;
c = a+b;
cout<< " addition is" << c<<endln;
}
if (choice == 2)
{
cout<< "enter first value :";
cin >> a;
cout<< "enter second value :";
cin >> b;
c = a - b;
cout<< " the subtraction is << c<<endln;
}
if (choice == 3)
{
cout<< "enter first value :";
cin>> a;
cout<< "enter second value :";
cin>> b;
c = a * b;
cout<< " the multiplication is << c<<endln;
}
if (choice == 4)
{
cout<< "\t\t\t thanks for using mini calcultor bye\n";
break;
}
if ( choice >= 5)
{
cout<< "\t\t\t invalid choice try again\n";
}
}
}
Re: C++ Beginner Discussion Room: Drop Your Codes by raynold(m): 12:51pm On Dec 14, 2013
I kinda(not like a pro) knw c, c++ and java
I dislike arrays and pointers
Re: C++ Beginner Discussion Room: Drop Your Codes by Nobody: 5:37pm On Dec 14, 2013
raynold: I kinda(not like a pro) knw c, c++ and java
I dislike arrays and pointers

Yu shld really start practicing pointers, coz they're very useful and yu gon always be making use of them! In c++ object oriented programming

(1) (2) (3) (4) (5) (Reply)

Letter From The Moderator - Please Read / How To Convert Folder/file To Jpeg Format / Computer Science/programming Challenging Questions

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 101
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.