-
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.
Showing
100 changed files
with
3,422 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,61 @@ | ||
#include<iostream> | ||
using namespace std; | ||
|
||
class ArrayX | ||
{ | ||
public: | ||
int * Arr; | ||
int iSize; | ||
|
||
ArrayX(int i) | ||
{ | ||
cout<<"Allocating the memory for resources...."<<"\n"; | ||
iSize = i; | ||
Arr = new int(iSize); // Arr = (int *)malloc(iSize * sizeof(int)); | ||
} | ||
|
||
~ArrayX() | ||
{ | ||
cout<<"Deallocating the memory of resources...."<<"\n"; | ||
delete []Arr; | ||
} | ||
|
||
|
||
void Accept() | ||
{ | ||
cout<<"Enter the elements of array : "<<"\n"; | ||
|
||
for(int iCnt = 0;iCnt < iSize;iCnt++) | ||
{ | ||
cin>>Arr[iCnt]; | ||
} | ||
} | ||
|
||
void Display() | ||
{ | ||
cout<<"Elements of array are : "<<"\n"; | ||
|
||
for(int iCnt = 0;iCnt < iSize;iCnt++) | ||
{ | ||
cout<<Arr[iCnt]<<"\t"; | ||
} | ||
cout<<"\n"; | ||
} | ||
}; | ||
|
||
int main() | ||
{ | ||
int iLength = 0; | ||
|
||
cout<<"enter the size of array : "<<"\n"; | ||
cin>>iLength; | ||
|
||
ArrayX * obj = new ArrayX(iLength); //Dynamic | ||
|
||
obj->Accept(); | ||
obj->Display(); | ||
|
||
delete obj; | ||
|
||
return 0; | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,55 @@ | ||
/* | ||
Row = 4 | ||
Col = 4 | ||
# 1 1 1 | ||
1 # 2 2 | ||
3 3 # 3 | ||
4 4 4 # | ||
*/ | ||
|
||
#include<stdio.h> | ||
|
||
void Display(int iRow, int iCol) | ||
{ | ||
int i = 0, j = 0; | ||
|
||
if(iRow != iCol) | ||
{ | ||
printf("Row number and column numbers are diffrent\n"); | ||
return; | ||
} | ||
|
||
for(i = 1; i<= iRow; i++) | ||
{ | ||
for(j = 1; j<=iCol; j++) | ||
{ | ||
if(i == j) | ||
{ | ||
printf("#\t"); | ||
} | ||
else | ||
{ | ||
printf("%d\t",i); | ||
} | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
int iValue1 = 0, iValue2 = 0; | ||
|
||
printf("Enter number of rows\n"); | ||
scanf("%d",&iValue1); | ||
|
||
printf("Enter number of columns\n"); | ||
scanf("%d",&iValue2); | ||
|
||
Display(iValue1,iValue2); | ||
|
||
return 0; | ||
} |
Binary file not shown.
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,33 @@ | ||
/* | ||
Row = 4; | ||
Col = 4; | ||
1 2 3 4 | ||
1 2 3 4 | ||
1 2 3 4 | ||
1 2 3 4 | ||
*/ | ||
|
||
#include<stdio.h> | ||
|
||
int main() | ||
{ | ||
int iValue1 = 0; | ||
int iValue2 = 0; | ||
|
||
printf("enter number of rows\n"); | ||
scanf("%d",&iValue1); | ||
|
||
printf("enter number of columns\n"); | ||
scanf("%d",&iValue2); | ||
|
||
Display(iValue1,iValue2); | ||
|
||
return 0; | ||
} | ||
|
||
void Display(int iRow, int iCol) | ||
{ | ||
|
||
} |
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,39 @@ | ||
// Problem statement : Accept number from user and check wheather it is divisible by 5 or not | ||
|
||
#include<stdio.h> | ||
#include<stdbool.h> | ||
|
||
bool DivisibleByFive(int iNo) | ||
{ | ||
int iAns = 0; | ||
iAns = iNo % 5; | ||
|
||
if(iAns == 0) | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
int main() | ||
{ | ||
int iValue = 0; | ||
bool bRet; | ||
|
||
printf("Enter number : \n"); | ||
scanf("%d",&iValue); | ||
|
||
bRet = DivisibleByFive(iValue); | ||
if (bRet == false) | ||
{ | ||
printf("%d is not divisible by 5",iValue); | ||
} | ||
else | ||
{ | ||
printf("%d is divisible by 5",iValue); | ||
} | ||
|
||
return 0; | ||
} |
Binary file not shown.
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,47 @@ | ||
//Row 4 | ||
//Columns 4 | ||
/* | ||
* * * * | ||
* * * * | ||
* * * * | ||
* * * * | ||
*/ | ||
|
||
#include<stdio.h> | ||
|
||
void Display(int iRow, int iCol) //N^2 | ||
{ | ||
int i = 0, j =0; | ||
if(iRow < 0) | ||
{ | ||
iRow = -iRow; | ||
} | ||
if(iCol < 0) | ||
{ | ||
iCol = -iCol; | ||
} | ||
|
||
for(i=1; i<=iRow;i++) | ||
{ | ||
for(j = 1;j <= iCol; j++) | ||
{ | ||
printf("*\t"); | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
int iValue1 = 0, iValue2 = 0; | ||
|
||
printf("Enter number of rows \n"); | ||
scanf("%d",&iValue1); | ||
|
||
printf("Enter number of columns \n"); | ||
scanf("%d",&iValue2); | ||
|
||
Display(iValue1,iValue2); | ||
|
||
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,47 @@ | ||
//Row 4 | ||
//Columns 4 | ||
/* | ||
* * * * | ||
* * * * | ||
* * * * | ||
* * * * | ||
*/ | ||
|
||
#include<stdio.h> | ||
|
||
void Display(int iRow, int iCol) //N^2 | ||
{ | ||
int i = 0, j =0; | ||
if(iRow < 0) | ||
{ | ||
iRow = -iRow; | ||
} | ||
if(iCol < 0) | ||
{ | ||
iCol = -iCol; | ||
} | ||
|
||
for(i=1; i<=iRow;i++) | ||
{ | ||
for(j = 1;j <= iCol; j++) | ||
{ | ||
printf("*\t"); | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
int iValue1 = 0, iValue2 = 0; | ||
|
||
printf("Enter number of rows \n"); | ||
scanf("%d",&iValue1); | ||
|
||
printf("Enter number of columns \n"); | ||
scanf("%d",&iValue2); | ||
|
||
Display(iValue1,iValue2); | ||
|
||
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,42 @@ | ||
/* | ||
Row = 4; | ||
Col = 4; | ||
1 2 3 4 | ||
1 2 3 4 | ||
1 2 3 4 | ||
1 2 3 4 | ||
*/ | ||
|
||
#include<stdio.h> | ||
|
||
|
||
void Display(int iRow, int iCol) | ||
{ | ||
int i =0, j =0; | ||
|
||
for(i=1; i<=iRow;i++) | ||
{ | ||
for(j=1; j <= iCol; j++) | ||
{ | ||
printf("%d\t",j); | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
int iValue1 = 0,iValue2 = 0; | ||
|
||
printf("enter number of rows\n"); | ||
scanf("%d",&iValue1); | ||
|
||
printf("enter number of columns\n"); | ||
scanf("%d",&iValue2); | ||
|
||
Display(iValue1,iValue2); | ||
|
||
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,42 @@ | ||
/* | ||
Row = 4; | ||
Col = 4; | ||
1 1 1 1 | ||
2 2 2 2 | ||
3 3 3 3 | ||
4 4 4 4 | ||
*/ | ||
|
||
#include<stdio.h> | ||
|
||
|
||
void Display(int iRow, int iCol) | ||
{ | ||
int i =0, j =0; | ||
|
||
for(i=1; i<=iRow;i++) | ||
{ | ||
for(j=1; j <= iCol; j++) | ||
{ | ||
printf("%d\t",i); | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
int iValue1 = 0,iValue2 = 0; | ||
|
||
printf("enter number of rows\n"); | ||
scanf("%d",&iValue1); | ||
|
||
printf("enter number of columns\n"); | ||
scanf("%d",&iValue2); | ||
|
||
Display(iValue1,iValue2); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.