Abod
Important Note: Write the explanations, pseudocode (algorithm) and flowcharts for all the questions using word processing software such as Microsoft word and then save them as a pdf document called StudentNumberExplainations.pdf Save every program separately, for example as Q1.c for question 1, Q2.c for question 2 , so on and so forth. Zip all the programs as a zip file called StudentNumberPrograms.zip. Upload the zip file and the pdf using the system portal. Solution to a question, without providing a flowchart, pseudocode as well as an explanation would not be considered for grading. Missing any of the vital components would result in getting a zero from that question: Vital components: 1. Well commented Program 2. Algorithm (pseudocode) 3. Explanation of the pseudocode 4. Flowchart 5. Explanation of the flowchart 6. General discussion on the program that explains why a certain technique was adopted Q1) (Sales-Commission Calculator) One large chemical company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9% of $5000, or a total of $650. Develop an algorithm, flowchart and program that will input each salespersons gross sales for last week and will calculate and display that salespersons earnings. Process one salesperson's figures at a time. Here is a sample input/output dialog: Enter sales in dollars (-1 to end): 5000.00 Salary is: $650.00 Enter sales in dollars (-1 to end): 1234.56 Salary is: $311.11 Enter sales in dollars (-1 to end): -1 Q2) (Pre-decrementing vs. Post-decrementing) Write an algorithm, flowchart and program that demonstrates the difference between pre-decrementing and post-decrementing using the decrement operator '--'.
Abod
Please i need help for these two questions
Anonymous
Important Note: Write the explanations, pseudocode (algorithm) and flowcharts for all the questions using word processing software such as Microsoft word and then save them as a pdf document called StudentNumberExplainations.pdf Save every program separately, for example as Q1.c for question 1, Q2.c for question 2 , so on and so forth. Zip all the programs as a zip file called StudentNumberPrograms.zip. Upload the zip file and the pdf using the system portal. Solution to a question, without providing a flowchart, pseudocode as well as an explanation would not be considered for grading. Missing any of the vital components would result in getting a zero from that question: Vital components: 1. Well commented Program 2. Algorithm (pseudocode) 3. Explanation of the pseudocode 4. Flowchart 5. Explanation of the flowchart 6. General discussion on the program that explains why a certain technique was adopted Q1) (Sales-Commission Calculator) One large chemical company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9% of $5000, or a total of $650. Develop an algorithm, flowchart and program that will input each salespersons gross sales for last week and will calculate and display that salespersons earnings. Process one salesperson's figures at a time. Here is a sample input/output dialog: Enter sales in dollars (-1 to end): 5000.00 Salary is: $650.00 Enter sales in dollars (-1 to end): 1234.56 Salary is: $311.11 Enter sales in dollars (-1 to end): -1 Q2) (Pre-decrementing vs. Post-decrementing) Write an algorithm, flowchart and program that demonstrates the difference between pre-decrementing and post-decrementing using the decrement operator '--'.
/warn assignment
Prince Of Persia
How to define lambda and how lambda work(in c++)
Prince Of Persia
Is lambda like a pointer to a function?
Prince Of Persia
No
Can you say how they work?
Pavel
Is lambda like a pointer to a function?
It's more like an object, but if you capture no data and don't do anything specific with lambda itself then it can be optimized to a function pointer. Example how it can look like for the compiler: https://cppinsights.io/s/aa7da5a3
Pavel
I want to use function in a vector My functions can be large Which one better? Pointer(to function) or lambda?
You need lambda if you want your functions to capture some data. If you don't need it, you can go with function pointers
Pavel
I mean not lambda but std::function type
Prince Of Persia
Pavel
Oh what is that type?
https://en.cppreference.com/w/cpp/utility/functional/function
Pavel
Basically a wrapper for callable things (function pointers, lambdas)
JOKER
Just asking one question:: Why companies don't allow you to code in online rounds in python? It's either in cpp or Java.
Pavel
Oh what is that type?
You need it beacause you can't create array of lambdas directly, because lambdas have "magic" types (generated types, see my link above)
JOKER
I don't know where to ask this
Anonymous
anyone has the OT group link
Shvmtz
printf("%c", '97'); printf("%d", '97'); Output: 7 97 Here, '97' is neither a character nor a string. What is it printing ?
Pavel
printf("%c", '97'); printf("%d", '97'); Output: 7 97 Here, '97' is neither a character nor a string. What is it printing ?
This states that it's multibyte character and that its value is implementation-defined https://stackoverflow.com/questions/7459939/what-do-single-quotes-do-in-c-when-used-on-multiple-characters
S
Anyone did u code a program in c program using all 32 keywords in ANSI C
S
Just like that curious to see if its possible or not
Anonymous
Does anyone have Google Task Mate?
S
Let's see
Георгий
I've read the rules and I agree with them
PaAaAria
hi, does anybody know newton-raphson method?, I have a problem with coding and I wonder if somebody could help me
PaAaAria
a very easy algorithm
yes, the algorithm is easy, but something is going wrong in my code and I don't understand why
Anonymous
and what is it
PaAaAria
I wrote a code which calculate the root of a parabolic function. when I entered an initial guess which is very close to the root it calculates the root accurately. the point is that if I make a further initial guess it shows the wrong root. imagine that the root is 1.06 if I only enter 1 or 2 the root is calculated correctly but if I insert 20 the root is wrong although there is no other root except 1.06 in this area
PaAaAria
I don't know what the reason is
PaAaAria
and what is it
here is the code https://hastebin.com/hemeyometi.cpp
Igor🇺🇦
here is the code https://hastebin.com/hemeyometi.cpp
Are you sure about line 48? Shouldn't it be || instead of |? Or abs (fnew) >= 0.0001?
PaAaAria
Are you sure about line 48? Shouldn't it be || instead of |? Or abs (fnew) >= 0.0001?
Abs(fnew) does not work And I think | means or in c++, doesn't it?
Igor🇺🇦
Abs(fnew) does not work And I think | means or in c++, doesn't it?
| as bit or, what you need is as logical or which is ||. Why doesn't abs work? You're using the same method 2 lines below
PaAaAria
| as bit or, what you need is as logical or which is ||. Why doesn't abs work? You're using the same method 2 lines below
Ooops, you're right, thx In that line I say if fnew is less than 0.0001 repeat the loop Actually when I used abs in here it goes into infinite loop and I don't Know the reason🤔
Igor🇺🇦
Ooops, you're right, thx In that line I say if fnew is less than 0.0001 repeat the loop Actually when I used abs in here it goes into infinite loop and I don't Know the reason🤔
And another question - about do while condition. It seems it should be the other way around. You want to stop when you reach close enough value, not continue. Am I missing something?
Parv
Hey , help me to learn C programing
Igor🇺🇦
Hey , help me to learn C programing
There plenty tutorials on the Internet.
Parv
I know , suggest me the best one
PaAaAria
And I don't Know What the problem is
PaAaAria
As you can see if I insert 30, for instance, it gives me the wrong answer
PaAaAria
Although there is only one root between 1 and 30
Prince Of Persia
Persian?
Yes she is
Igor🇺🇦
Yes exactly, and it works if I only enter 1 as an initial value
It will stop when it reaches difference larger than 0.00001 meaning after the first loop.
PaAaAria
Igor🇺🇦
Either I don't understand what your algorithm is trying to do or your condition should be the other way around while >, not while <
Igor🇺🇦
Either I don't understand what your algorithm is trying to do or your condition should be the other way around while >, not while <
It should be "If the difference is too large continue" . In you case it continues while difference is too small.
PaAaAria
It should be "If the difference is too large continue" . In you case it continues while difference is too small.
I understand your word But the thing is why it's calculating the correct root when the input is very close to the root (the root is 1.06)
Anonymous
So u must make sure the beginning is not too far from thr root
PaAaAria
It should be "If the difference is too large continue" . In you case it continues while difference is too small.
I used newton-raphson method to calculate the root. Should this method Work when we insert a furthur initial value?
PaAaAria
It probably breaks on condition in line 44
Give me a second to check it plz
PaAaAria
For example for initial value 30 it gives me 15.27 as the root
PaAaAria
But if I use <= the answer is around 0.17
PaAaAria
You know the point is that
PaAaAria
Two conditions are checked Here to find the reasonable root. The if condition checks the function value of the d to understand whether it is small or not And the while checks the substraction of dnew from the initial value and if it is also small the loop stops
PaAaAria
It probably breaks on condition in line 44
I think you're right The condition should be changed but when I reverse it, it doesn't help🤔
Vitalii
#include <stdio.h> #include <stdarg.h> #define N 100 void MaxElem(int, ...); int main() { MaxElem(34, 55, 89, 144, 0, 1, 1, 2, 233, 337, 90, -1); return 0; } void MaxElem(int n, ...) { int arr[N] = {0}; int temp; int j=0; va_list (arg_list); va_start(arg_list, n); while((temp = va_arg(arg_list, int))>=0) { arr[j] = temp; printf("\narr[j] = %d\n", arr[j]); j++; } va_end (arg_list); } Why does my program skip number "34"? I just can't catch it((
Vitalii
34 is passed as n, isn't it?
Oh, yes....i forgot about that...can I somehow avoid it?
Vitalii
I'm sorry...for me that's new 😅
Pavel
Oh, yes....i forgot about that...can I somehow avoid it?
I never used these variadic functions, but I think you can remove it so your function signature is void MaxElem(...)
Pavel
Hm, or maybe not, can't find any examples
Vitalii
Oh, I just fount out that n works only with macros, so I can't use it in this way, only if I write amount of numbers...