Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions 1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,39 @@

using namespace std;

long long *b;
long double* b;

long long int factorial(int n)
long double factorial(int n)
{
return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;
}

long long int *producingTheFactorialFractions()
long double* producingTheFactorialFractions()
{
long long b[10];
//memory allocation for b
b = new long double[10];

for (int i = 10; i >= 0; i--)
//i must be 9
for (int i = 9; i >= 0; i--)
{
b[i] += (int)pow(factorial(10), 2.0) / (i + 1);
b[i] = (long double)pow(factorial(10), 2.0) / (i + 1);
}
return b;
}

void checkZeros(long long *a)
void checkZeros(long double* a)
{
for (int i = 9; i >= 0; i--)
{
if (a[i] = 0)
{//2 ta mosavy
if (a[i] == 0)
cout << "Zero Found" << endl;
}
}

int main()
{

long long int *a;
long double* a;
a = producingTheFactorialFractions();
checkZeros(a);
for (int i = 0; i < 10; i++)
Expand All @@ -43,8 +45,20 @@ int main()
}
delete a;

cout<<"hello";
cout<<"Bye";

cout << "hello";
cout << "Bye";

/*
1.31682e+13
6.58409e+12
4.3894e+12
3.29205e+12
2.63364e+12
2.1947e+12
1.88117e+12
1.64602e+12
1.46313e+12
1.31682e+12
helloBye
*/
}
11 changes: 7 additions & 4 deletions 2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ using namespace std;

// count all the specific char in the whole array of strings
int countAllSpecificChars(string sArr[], int arrLength, char specificChar) {
int count;
for (int i = 0; i <= arrLength; ++i)
for (int j = 0; j <= sArr[i].size(); ++j)
//intialized count
int count = 0;
//i++
for (int i = 0; i < arrLength; i++)
//j++
for (int j = 0; j < sArr[i].size(); j++)
// if the jth char of the string is the specific char
if (sArr[i][j] = specificChar)
if (sArr[i][j] == specificChar)
count++;
return count;
}
Expand Down
13 changes: 7 additions & 6 deletions 3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#define MAX_SIZE 200
int arr[MAX_SIZE];

typedef struct alfa * alfaptr;
typedef struct alfa* alfaptr;

struct alfa {
long long x;
//long long int
long long int x;
alfaptr next;
};
alfaptr rear = NULL, front = NULL;
Expand Down Expand Up @@ -45,7 +46,7 @@ void search(int x)
printf("ERROR2");
break;
}
node = node->next;
node = node->next;
}

void rpop() {//pop last element
Expand All @@ -66,9 +67,9 @@ void set()
int size()
{
alfaptr node = front;
int count;
int count = 0;
while (node)
count++;node = node->next;
count++; node = node->next;
return count;
}

Expand All @@ -88,7 +89,7 @@ int average()
{

alfaptr node = front;
int sum = 0, count;
int sum = 0, count = 0;
while (node) {
sum += node->x;
count++;
Expand Down
1 change: 1 addition & 0 deletions 4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ int main()
float *ptr2 = ptr1 + 3;
printf("%f", *ptr2 - *ptr1);
return 0;
//78.000000
}
2 changes: 2 additions & 0 deletions 5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ int main()
printf("%d\n", (*ptr2 - *ptr1));
printf("%c", (char)(*ptr2 - *ptr1));
return 0;
//50
//2
}
1 change: 1 addition & 0 deletions 6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ int main()
x[0] = 1;
printf("%d\n", a);
return 0;
//513
}
1 change: 1 addition & 0 deletions 7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ int main()
p += 2;
printf("%d", *p);
return 0;
//3
}
2 changes: 1 addition & 1 deletion 8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ int main() {
printf("%c%c%c%c\n", **str, *(*(str + 1) + 1), *((str + 2)[-1] + 1), **&*(&str[-1] + 1));



//Be WooW
}