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
8 changes: 4 additions & 4 deletions 2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ 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)
int count = 0; //variable count wasnt initialized
for (int i = 0; i < arrLength; i++)//"<="changed to "<"
for (int j = 0; j < sArr[i].size(); j++)//"<="changed to "<"
// if the jth char of the string is the specific char
if (sArr[i][j] = specificChar)
if (sArr[i][j] == specificChar)//"="changed to "=="
count++;
return count;
}
Expand Down
8 changes: 5 additions & 3 deletions 4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
int main()
{
float arr[5] = { 12.5, 10.0, 13.5, 90.5, 0.5 };
float *ptr1 = &arr[0];
float *ptr2 = ptr1 + 3;
float* ptr1 = &arr[0];
float* ptr2 = ptr1 + 3;
printf("%f", *ptr2 - *ptr1);
return 0;
}
}
//no problem
//78
8 changes: 5 additions & 3 deletions 5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
int main()
{
int arr[] = { 10, 20, 30, 40, 50, 60 };
int *ptr1 = arr;
int *ptr2 = arr + 5;
int* ptr1 = arr;
int* ptr2 = arr + 5;
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 @@ -9,3 +9,4 @@ int main()
printf("%d\n", a);
return 0;
}
//513
3 changes: 2 additions & 1 deletion 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
1 change: 1 addition & 0 deletions 8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ int main() {


}
//Be WooW