0% found this document useful (0 votes)
53 views

Project in Programming

This document contains a project in computer programming. It includes 12 sections that demonstrate different programming concepts in C++ like data types, functions, control flow statements, and basic arithmetic operations. The sections provide code examples to add, subtract, multiply and divide numbers, use variables, if/else statements, loops, and define reusable functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Project in Programming

This document contains a project in computer programming. It includes 12 sections that demonstrate different programming concepts in C++ like data types, functions, control flow statements, and basic arithmetic operations. The sections provide code examples to add, subtract, multiply and divide numbers, use variables, if/else statements, loops, and define reusable functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PROJECT

IN
COMPUTER
PROGRAMMING

Ran Denver B. Natividad

Sir. Rhimshie Aquino


1.HELLO WORD int x,y;
#include <iostream> cout<<"Please Enter 2 Numbers to
Solve"<<endl;
using namespace std; cin>>x;
cin>>y;
int main() subtraction(x,y);
{ return 0;
cout << "Hello world!" << endl; }
return 0;
}

 MULTIPLICATION
2. VARIABLES #include <iostream>
 ADDITION using namespace std;
#include <iostream> void product (int x, int y)
using namespace std; {
void addition (int x, int y) cout << "The product is " <<x*y<< endl;
{ }
cout << "The sum is " <<x+y<< endl; int main()
} {
int main() int x,y;
{ cout<<"Please Enter 2 Numbers to
int x,y; Solve"<<endl;
cout<<"Please Enter 2 Numbers to cin>>x;
Solve"<<endl; cin>>y;
cin>>x; product(x,y);
cin>>y; return 0;
addition(x,y); }
return 0;
}

 DIVISION
#include <iostream>
 SUBTRACTION using namespace std;
#include <iostream> void divide (int x, int y)
using namespace std; {
void subtraction (int x, int y) cout << "The qoutient is " <<x/y<< endl;
{ }
cout << "The subtract is " <<x-y<< endl; int main()
} {
int main() int x,y;
{
cout<<"Please Enter 2 Numbers to {
Solve"<<endl; int x= 5;
cin>>x; int y= 10;
cin>>y;
divide(x,y); cout<<x+y<<endl;
return 0; return 0;
} }

5. IF ELSE STATEMENT
#include <iostream>
3. BASIC CALCULATOR using namespace std;
#include <iostream> int main ()
using namespace std; {
int main() int Age;
{ cout<<"Enter Age"<<endl;
int x,y; cin>>Age;
cout<< "Insert first number" <<endl; if(Age>17)
cin>>x; {
cout<< "Insert second number" <<endl; cout<< "Ready to vote" <<endl;
cin>>y; }
int sum=x+y; else
int subtract=x-y; {
int product=x*y; cout<<"Not Ready to vote"<<endl;
float quotient=x/y; }
int remainder=x%y; return 0;
cout<< "The sum is =" <<sum <<endl; }
cout<< "The subtract is =" <<subtract <<endl;
cout<< "The product is =" <<product <<endl;
cout<< "The quotient is =" <<quotient <<endl;
cout<< "The remainder is =" <<remainder
<<endl;
return 0; 6. SWITCH STATEMENT
} #include <iostream>
using namespace std;
int main()
{
char grade;
cout<<"Please Enter Grade"<<endl;
cin>> grade;
switch (grade)
{
case 'A':cout<<"90-100\nExcellent"<<endl;
4. BASIC ARITHMETIC break;
#include <iostream> case 'B':cout<<"80-89\nVery Good"<<endl;
using namespace std; break;
int main()
case 'C':cout<<"75-79\nPassed"<<endl; #include <iostream>
break; using namespace std;
default: int main()
cout<<"Invalid Entry"<<endl; {
} int x=85;
return 0; x++;
} cout<<x<<endl;
return 0;
}

7. FOR LOOP  DECREMENT


#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() int main()
{ {
for (int i=1; i<=55; i+=5) int x=85;
{ x--;
cout<<i<<endl; cout<<x<<endl;
} return 0;
return 0; }
}

10. FUNCTION PASSING PARAMETERS


USING VOID
#include <iostream>
using namespace std;
void sum(int x,int y)
{
cout<<"the sum is="<<x+y<<endl;
8. WHILE LOOP cout<<"the subtract is="<<x-y<<endl;
#include <iostream> cout<<"the product is="<<x*y<<endl;
using namespace std; cout<<"the divide is="<<x/y<<endl;
int main() }
{ int main()
int x=1; {
while (x<=1) int x,y;
{ cout<< "insert two number" << endl;
cout<<x<<endl; cin>>x;
} cin>>y;
return 0; sum(x,y);
} return 0;
}
9. INCREMENT DECREMENT VALUE
 INCREMENT
11. RETURN VALUE IN FUNCTIONS USING INT 12. FUNCTION
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int sum (int firstno,int secondno) void MYFIRSTFUNCTION()
{ {
int result =1; cout<<"We Are on a Funtion"<<endl;
result=firstno+secondno; }
} int main()
int main() {
{ MYFIRSTFUNCTION();
int multiply =10; MYFIRSTFUNCTION();
int mainresult; MYFIRSTFUNCTION();
mainresult=multiply*sum(50,70); MYFIRSTFUNCTION();
cout<<"result is "<<mainresult<<endl; MYFIRSTFUNCTION();
return 0; MYFIRSTFUNCTION();
} MYFIRSTFUNCTION();
MYFIRSTFUNCTION();
MYFIRSTFUNCTION();
MYFIRSTFUNCTION();
return 0;
}

You might also like