-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b3fd6be
Showing
5 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/***************************************************************************** | ||
MAIA Master M1 | ||
Software Engg. : Practise Excersice 1 | ||
*******************************************************************************/ | ||
// Problem 1 | ||
//C++ Program to find the area of the circle using function | ||
#include<iostream> | ||
using namespace std; | ||
float area(float); | ||
float circumference(float); | ||
|
||
int main() | ||
{ | ||
int diameter; | ||
cout<<"\n Enter Diameter of the Circle: "; | ||
cin>>diameter; | ||
cout<<"\n Area of the Circle : "<<area(diameter); | ||
cout<<"\n Circumference of the Circle : "<<circumference(diameter); | ||
} | ||
float area(float diameter) | ||
{ | ||
return (3.14 * (diameter/2) * (diameter/2) ); | ||
} | ||
float circumference(float diameter) | ||
{ | ||
return(3.14 * diameter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Problem 2 | ||
//C++ Program to find the max and the min of a table. | ||
|
||
#include <iostream> | ||
using namespace std; | ||
|
||
int Max(int a[],int n) | ||
{ | ||
int i, max; | ||
max = a[0]; | ||
for(i=1;i<n;i++) | ||
{ | ||
if(a[i]>max) | ||
max =a[i]; | ||
} | ||
return max; | ||
} | ||
|
||
int Min(int a[],int n) | ||
{ | ||
int i, min; | ||
min = a[0]; | ||
for(i=1;i<n;i++) | ||
{ | ||
if(a[i]<min) | ||
min =a[i]; | ||
} | ||
return min; | ||
} | ||
|
||
int main() | ||
{ | ||
int i, array[50], size, max, min; | ||
|
||
cout<<"Input size of array\n"; | ||
cin>>size; | ||
|
||
cout<<"Enter "<< size << " integers\n"; | ||
for(i=0;i<size;i++) | ||
cin>>array[i]; | ||
|
||
max = Max(array,size); | ||
min = Min(array,size); | ||
|
||
cout<<"Maximum element in the array is:" << max << "\n"; | ||
cout<<"Minimum element in the array is:" << min << "\n"; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Problem 3 | ||
//C++ Program to compute the Fibonacci sequence. | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int fib(int n) | ||
{ | ||
int a = 0, b = 1, c, i; | ||
if( n == 0) | ||
return a; | ||
for(i = 2; i <= n; i++) | ||
{ | ||
c = a + b; | ||
a = b; | ||
b = c; | ||
} | ||
return b; | ||
} | ||
|
||
int main() | ||
{ | ||
int n; | ||
cout<<"Input rank of the sequence : "; | ||
cin>>n; | ||
cout <<"The fibbonacci number at " << n << " rank is: " << fib(n); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Problem 4 | ||
//C++ Program to display in the terminal any multiplication table | ||
#include <iostream> | ||
using namespace std; | ||
|
||
void multi_table(int n, int i) | ||
{ | ||
if (i > 10) | ||
return; | ||
|
||
cout << n << " * " << i << " = " << n * i << endl; | ||
|
||
return multi_table(n, i + 1); | ||
} | ||
|
||
|
||
int main() | ||
{ | ||
int n; | ||
cout << "Enter an integer: "; | ||
cin >> n; | ||
|
||
multi_table(n, 1); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Problem 5 | ||
//C++ Program to compute the truth table of the AND & OR operators using 3 variable as input. | ||
#include<iostream> | ||
|
||
int main() | ||
{ | ||
|
||
std::cout<<"Truth Table for AND operator\n"; | ||
truth_table_AND(); | ||
std::cout<<"Truth Table for OR operator\n"; | ||
truth_table_OR(); | ||
|
||
return 0; | ||
} | ||
|
||
void truth_table_OR() | ||
{ | ||
int i,j,k; | ||
|
||
for(i=0;i<=1;i++) | ||
{ | ||
for(j=0;j<=1;j++) | ||
{ | ||
for(k=0;k<=1;k++) | ||
{ | ||
std::cout << '\t' << i << ' ' << j << ' ' << k << " --> "<< (i||j||k) << '\n'; | ||
} | ||
} | ||
} | ||
return; | ||
} | ||
|
||
|
||
void truth_table_AND() | ||
{ | ||
int i,j,k; | ||
|
||
for(i=0;i<=1;i++) | ||
{ | ||
for(j=0;j<=1;j++) | ||
{ | ||
for(k=0;k<=1;k++) | ||
{ | ||
std::cout << '\t' << i << ' ' << j<< ' ' << k <<" --> " << (i&&j&&k) << '\n'; | ||
} | ||
} | ||
} | ||
return; | ||
} | ||
|
||
|