Al
if you multiply in a loop by 0 .... the result is always 0
Al
i%2 doesn’t give you even numbers as you expected
Al
sorry i see multiple errors
✙Олег!?
it is multiplied by 5 (
✙Олег!?
5х5=25 25х5=125 .....
Pavel
it is multiplied by 5 (
Oh gosh, yes, you index your N, not arr :) Wonder how it even compiled :)
Mueen
can any one help me in my exam?
Al
Oh gosh, yes, you index your N, not arr :) Wonder how it even compiled :)
well i don’t agree a[i] is compiled in the same way as i[a] and have the same meaning... is weird but for the compiler there is no difference .
Al
have a try
Al
oh yes correct
✙Олег!?
void main() { int N; int arr[5]{ 32, 7, 2, 18, 88 }; int dob; for (int i = 0; i < 5; i++) { if ((i % 2) ==0); dob = arr[0]*arr[2]*arr[4]; cout << dob << endl; } }
✙Олег!?
I marvel at my bad skill
✙Олег!?
to complete the task - 8 hours, a great night
Anonymous
hi how can i do this in C? 13453.61521 i want to print separately 13453 and 61521(without 0.)
klimi
hi how can i do this in C? 13453.61521 i want to print separately 13453 and 61521(without 0.)
https://stackoverflow.com/questions/499939/how-to-extract-the-decimal-part-from-a-floating-point-number-in-c#499943
✙Олег!?
guys heeelp
✙Олег!?
In a one-dimensional array consisting of N integer elements, calculate: - the product of the elements of the array with even numbers.
Bruno
Hi, do you know any c/c++ junior or internship opportunity? I'm really needing a job.
Bruno
Me sir
Tell me more >.<
✙Олег!?
how to combine this code with the previous one
correctmaninwrongplace
if you arent using some gist like the pinned message suggest, i advise to: 1. delete comments, unless extreme necessary 2. add 3x` and 3x` after the code so it be formatted, for example; int main() { const int N = 10; int array[N]; int sum = 0; /*your other code*/ } it will help to read your code
correctmaninwrongplace
Anonymous
//18101202 김영균 #include <iostream> #include <string> using namespace std; class Student { public: Student(); ~Student(); void InputData(); // Input all data from user void OutputData(); // Output class list to console void ResetClasses(); // Reset class list Student& operator =(const Student& rightSide); // Assignment operator private: string name; int numClasses; string *classList; }; Student::Student() { numClasses = 0; classList = NULL; } Student::~Student() { delete[] classList; } void Student::InputData() { cout << "Enter student name." << '\n'; getline(cin, name); cout << "Enter number of classes." << '\n'; cin >> numClasses; cin.ignore(); classList = new string[numClasses]; for (int i = 0; i < numClasses; i++) { cout << "Enter name of class " << i + 1 << '\n'; getline(cin, classList[i]); } cout << '\n'; } void Student::OutputData() { cout << "Name: " << name << '\n'; cout << "Number of classes: " << numClasses << '\n'; for (int i = 0; i < numClasses; i++) { cout << " Class " << i + 1 << ": " << classList[i] << '\n'; } cout << '\n'; } void Student::ResetClasses() { numClasses = 0; if (classList != NULL) { delete[] classList; classList = NULL; } } Student& Student::operator=(const Student& rightSide) { name = rightSide.name; numClasses = rightSide.numClasses; classList = new string[numClasses]; for (int i = 0; i < numClasses; i++) { classList[i] = rightSide.classList[i]; } return *this; } int main() { // Test our code with two student classes Student s1, s2; s1.InputData(); // Input data for student 1 cout << "Student 1's data:" << endl; s1.OutputData(); // Output data for student 1 cout << endl; s2 = s1; cout << "Student 2's data after assignment from student 1:" << endl; s2.OutputData(); // Should output same data as for student 1 s1.ResetClasses(); cout << "Student 1's data after reset:" << endl; s1.OutputData(); // Should have no classes cout << "Student 2's data, should still have original classes:" << endl; s2.OutputData(); // Should still have original classes cout << endl; return 0; }
Anonymous
Improve the above C++ program code that meets the following requirements: • The improved code must include the Inheritance, Polymorphism (i.e., virtual function), and Template. Under the constraints of meeting these three requirements, you may add any functionalities that you want. Your scores depend on how perfectly these are reflected. • The driver function (i.e., main function) needs to be modified to best present your own functionalities and improvements that you implement. (Of course, the other parts in the above code may also be modified or improved) • Your code has to be able to WORK in Visual Studio or any other C++ complier WITHOUT ANY ERROR. If it does not work, the score is zero. Hence, the correct code operation is more important than a long code. • We will score your code through copying-and-pasting your code to Visual Studio then running it.
Anonymous
can you help to me,bruh?
Anonymous
why do y'all mf always put your entire homework here wishing for someone to do it damn
Anonymous
Xudoyberdi
Please, Winnie Pooh, don't get angry, kids will need you in cartoons
Suka
hi how can i do this in C? 13453.61521 i want to print separately 13453 and 61521(without 0.)
convert to string, separate and convert back to int. but i believe u have this solution before? goodluck
Yazidi
I've a question regarding "Reference", what is the difference between: &a = b; &a = &b; if a and b are variables. actually, I didn't get the answer ! Thank you in advance
Roshan
Int &a = b; Here a is the alias or the reference of b
Anonymous
&a is an address
Yazidi
so (&a = b;) and (Int* a = &b;) both of them are same, right?! I mean they do the same..!
Roshan
so (&a = b;) and (Int* a = &b;) both of them are same, right?! I mean they do the same..!
No! When & symbol is on the right side of equation, it's the memory address. When & symbol is on the left side of equation, it's the reference
Roshan
so (&a = b;) and (Int* a = &b;) both of them are same, right?! I mean they do the same..!
Int &a = b; here a is reference of b Int* a = &b; here a is pointer and &b is the address of b
Roshan
so the pointer "*a" here is holding a value, right?
Yes. Consider: Int b = 5; Int *a = &b; Cout<<*a; The output will be 5
Roshan
But if you say cout<<a; it prints the memory address of b
Roshan
thanks
Yeah I guess many struggle on this 😅
Yazidi
thanks a lot
Roshan
Welcome🤗
Roshan
I guess you should save these examples as in my experience I forgot them a lot of time 😂
Anonymous
what is compiler hacking ?
Roshan
what is compiler hacking ?
The first one says: Compiler hacking for source code analysis.
Anonymous
which is first one ?
Roshan
Google it 😅 IDK hacking...
Anonymous
I did .I got some events and some functional programming languages and finally got it is something related to LLVM
Yazidi
Int &a = b; Here a is the alias or the reference of b
can you gimme an example for this, please..🙈 because it confuses me also,😬🌷
Yazidi
alright👌🏼🌷
Z
preincrement ++i and post increment i++ can be used interchangeably in while loop ?
olli
preincrement ++i and post increment i++ can be used interchangeably in while loop ?
No, it's not the same and depends on how you use it.
olli
In for-loop it's same
not necessarily. #include <stdio.h> int main() { for (int i = 10; --i;) { printf("."); } puts(""); for (int i = 10; i--;) { printf("."); } }
Z
while (++i < 10) first increments i , then checks the condition wheras while (i++<10) first checks conditions then increments i . The essence is the same as ultimately the program has to stop as soon as i=10.
olli
Not the standard way to write. There are 3 arguments
there are three, the last one is empty, which is valid - here with 3 one. There is no "standard" way as this is compliant with both C and C++. #include <stdio.h> int main() { for (int i = 10, x = 1; x; x = --i) { printf("."); } puts(""); for (int i = 10, x = 1; x; x = i--) { printf("."); } }
Z
for ++i < 10 you basically do i += 1 i < 10 for i++ < 10 you do i < 10 i += 1 which is not the same since the order is reversed
but nevertheless both programs will be terminated as soon as i ==10 , so what diff does it make ?