100% found this document useful (1 vote)
50 views

Programming Fundamentals Assignment

The document contains 10 C++ programs demonstrating basic programming concepts like division, comparison operators, conditional statements, loops, functions etc. Program 1 divides two numbers and checks for zero division. Program 2 compares two numbers. Program 3 checks if a number is positive, negative or zero.

Uploaded by

Humaira Qasim
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
100% found this document useful (1 vote)
50 views

Programming Fundamentals Assignment

The document contains 10 C++ programs demonstrating basic programming concepts like division, comparison operators, conditional statements, loops, functions etc. Program 1 divides two numbers and checks for zero division. Program 2 compares two numbers. Program 3 checks if a number is positive, negative or zero.

Uploaded by

Humaira Qasim
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/ 7

PROGRAM 1

//DIVISION OF A NUMBER ALSO CHECK IF A NUMBER IS ZERO OR NOT

#include <iostream>

using namespace std;

int main(){

int num1;

cout << "enter num1: ";

cin >> num1;

int num2;

cout << "enter num2: ";

cin >> num2;

int divide;

if (num2==0){

cout << "you have entered a wrong number.";

} else{

divide = num1/num2;

cout << "your entered number division is: "<< divide;

return 0;

PROGRAM 2

// TO CHECK WHICH NUMBER IS GREATER

#include <iostream>

using namespace std;

int main(){
int num1;

cout << "enter num1: ";

cin>> num1;

int num2;

cout << "enter num2: ";

cin >> num2;

if (num1>num2){

cout <<"Num1 is greater.";

} else{

cout <<"Num2 is greater.";

return 0;

PROGRAM 3

//TO CHECK IF A NUMBER IS POSITIVE NEGATIVE OR ZERO

#include <iostream>

using namespace std;

int main(){

int num;

cout << "enter a number: ";

cin >> num;

if (num>0){

cout << "number is positive.";

} else if (num<0){

cout << "number is negative.";

} else {
cout << "number is Zero.";

return 0;

PROGRAM 4

#include <iostream>

using namespace std;

int main(){

int sale;

cout << "enter your sale: ";

cin >> sale;

double profit;

if (sale>10000){

profit = sale * 0.15;

cout << "your profit is: "<< profit;

} else {

profit = sale * 0.12;

cout << "your profit is: " << profit;

return 0;

PROGRAM 5

//FIND THE AREA

#include <iostream>

using namespace std;

int main() {
int r;

double area,pi=3.14;

cin>>r;

if(r>=0){

area = pi * r * r;

cout << "area is: "<< area;

} else{

cout << "enter positive value radius";

return 0;

PROGRAM 6

//TO CHECK IF A GIVEN NUMBER IS EVEN OR ODD

#include <iostream>

using namespace std;

int main(){

int num;

cout << "enter a number: ";

cin >> num;

if (num%2==0){

cout << "your entered number is Even number.";

} else {

cout << "your entered numeber is Odd number.";

return 0;
}

PROGRAM 7

// TO PRINT THE TABLE OF NUMBER ENTERED BY USER

#include <iostream>

using namespace std;

int main(){

int num;

cout << "enter a number whose table do you want to print: ";

cin >> num;

cout << num << "x"<< "1"<< "="<< num*1<<endl;

cout << num<< "x"<< "2"<< "="<< num*2<<endl;

cout << num << "x"<< "3"<< "="<< num*3<<endl;

cout << num << "x"<< "4"<< "="<< num*4<<endl;

cout << num<< "x"<<"5"<< "="<< num*5<<endl;

cout << num<< "x"<<"6"<< "="<< num*6<<endl;

cout << num<< "x"<<"7"<< "="<< num*7<<endl;

cout << num<< "x"<<"8"<< "="<< num*8<<endl;

cout << num<< "x"<<"9"<< "="<< num*9<<endl;

cout << num<< "x"<<"10"<< "="<< num*10<<endl;

PROGRAM 8

#include <iostream>

using namespace std;

int main(){

int a;
int b;

a = 5;

b = 10;

bool truevalue, falsevalue;

truevalue = (a<b);

falsevalue = (a==b);

cout << "true is "<< truevalue<<endl;

cout << "false is " << falsevalue << endl;

return 0;

PROGRAM 9

#include <iostream>

using namespace std;

int main(){

int a;

cout << "enter your working hours: ";

cin >> a;

int b;

cout << "enter your hour rate: ";

cin >> b;

int pay;

pay = a*b;

cout << "your pay is: " <<pay;

return 0;

}
PROGRAM 10

#include <iostream>

using namespace std;

int main(){

double a = 1;

cout << "the size of" << " " << a << " is "<< sizeof a << " bytes";

return 0;

You might also like