OOP Assignment 1
OOP Assignment 1
/*#include <iostream>
using namespace std;
int main()
{
int a, b, sum=0;
cout << "Enter two integers: ";
cin >> a >> b;
sum = a + b;
cout << a << " + " << b << " = " << sum;
return 0;
}
*/
//Program-3//
/*#include<iostream>
using namespace std;
int main()
{
int a;
cout << "Enter the number : ";
cin >> a;
if (a % 2 == 0)
cout << a << " is an even integer ";
else
cout << a << " is an odd integer ";
return 0;
}
*/
//Program-4//
/*#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int n;
cout<<"Enter number for day: ";
cin>>n;
switch(n)
{
case 1: cout<<"Sunday"; break;
case 2:
cout<<"Monday";
break;
case 3:
cout<<"Tuesday";
break;
case 4:
cout<<"Wednesday";
break;
case 5:
cout<<"Thursday";
break;
case 6:
cout<<"Friday";
break;
case 7:
cout<<"Saturday";
break;
default:
cout<<"Invalid number!";
break;
}
return 0;
}
*/
//Program 5//
/*#include <iostream>
int main() {
int input;
for (int input = 1; input <= 10; input++) {
std::cout << "\n" << input;
}
}
*/
/*#include <iostream>
using namespace std;
int main(){
int a,b;
for(a=1;a<=5;a++)
{
for(b=1;b<=a;b++)
{
count<<"*";
}
count<<"\n";
return(0);
}
*/
//TASK-2//
/*#include <iostream>
using namespace std;
int main()
{
int a=15, b=55;
cout<<"Before swap a= "<<a<<" b= "<<b;
a=a*b;
b=a/b;
a=a/b;
cout<<"After swap a= "<<a<<" b= "<<b;
return 0;
}
*/
/*#include <iostream>
using namespace std;
int main()
{
int a,b,c,greatest;
cout<<"Enter three numbers : ";
cin>>a>>b>>c;
greatest=(a>b&&a>c)?a:(b>c)?b : c;
cout<<"Greatest number is "<<greatest;
return 0;
}
*/
/*#include<iostream>
using namespace std;
int main()
{
int days,y,m,d;
cout<<"Enter no. of days : ";
cin>>days;
y=days/365;
days=days%365;
m=days/30;
d=days%30;
cout<<"Years : "<<y<<"\nMonths : "<<m<<"\nDays : "<<d;
return 0;
}
*/
//Object Oriented programming (OOP) is a programming paradigm that relies on the concept of
classes and objects. It is used to structure a software program into simple, reusable pieces of
code blueprints (usually called classes), which are used to create individual instances of
objects.//
//The main difference between both these languages is C is a procedural programming
language and does not support classes and objects, while C++ is a combination of both
procedural and object-oriented programming languages.//