klimi
okay
klimi
do you open the file as write or as append?
M
what do you mean
klimi
do you rewrite the file everytime you call Save()?
M
do you rewrite the file everytime you call Save()?
It should not, although it is possible. But problem is that '1' corresponds to another key which I am not pressing. The program doesnt log the right values
Anonymous
Anonymous
how can add multiple subject values for each student?
Mar!o
you alreay have ptr for array
Mar!o
just do calloc(num, sizeof(student));
Mar!o
but remember to check for failture
Anonymous
Thank you!
manas
Instead of arr[i], use arr[i].val, where val is the int in the struct. Isn't that what you're looking for?
András
I wonder how'd you make 3D games using an egine that runs on C
Lol. OpenGL is written in C. Vulcan is written in C
Anonymous
i have to calculate sum of 2 same sized arrays using a function. code is working fine but calculation is wrong . any solution. thanks
Anonymous
umm sum ? :/
András
In first loop you calculate sum of arr+n*0. In second loop you calculate sum of parr+n*sum of arr
Alion🦁
i have to calculate sum of 2 same sized arrays using a function. code is working fine but calculation is wrong . any solution. thanks
You have to write it, inside one for loop. In this situation, you're adding second every loop's element with sumtemp (which is the sum of numbers inside first array)
Alion🦁
if i am wrong correct me
András
And don't use global variables
Anonymous
So you return sum of parr+n*sum of arr
i have to get return , sum of both arrays when user inputs the elements. i did here is ,calculate first sum ,assigned it to sumtemp and , added to the next array.
Anonymous
thanks my g
Anonymous
also are there any unnecessary variable declarations ?
Asad
also are there any unnecessary variable declarations ?
don't use global variables. pay attention to indentation.
Anonymous
thanks both of u :)🙏🏼
Alion🦁
i have to calculate sum of 2 same sized arrays using a function. code is working fine but calculation is wrong . any solution. thanks
@coincards , can i ask one question? Why don't you create new array(newArr) in your array function and create one for loop (newArr[i]=arr[i]+parr[i]) and at last, return newArr
András
I mean sum of each elements in 2 arrays
Alion🦁
I see. Is it given that both of them is 2 dimensional?
Alion🦁
wait, i I will send the code.
Alion🦁
Now, i am at online lesson. Can we discuss later? 😕🙏
Anonymous
sure
Alion🦁
I will return as soon as possible
Anonymous
thanks 🙏🏼 mate
Alion🦁
@coincards can you give me input and outputs?
Alion🦁
i couldn't stay without solving it 😂
Anonymous
hahaa
Anonymous
@coincards can you give me input and outputs?
u mean test data ? you can use any number. :/ i entered 5 elements for both of arrays . 1, 2,3,4,5 to test
Alion🦁
I need to see is it working or not
Anonymous
i mean getting sum of those data is same mechanism right ?
Anonymous
for any number
Alion🦁
for example, consider, i wrote sum function. I must test it so, i give 1 and 2=> if it gave me 3 it means it's working.
Alion🦁
So, now, i want to receive 1 and 2 (inputs) from you. And, if 3 (result) equals to our expected value, it will mean yeah, our function works well
Anonymous
i entered 5 elements for both of arrays. since the question is about sum of 2 same sized arrays. so my test data was 1,2,3,4,5 for both arrays. so sum is going to be 1+2+3+4+5 +1+2+3+4+5 = 30
Alion🦁
okay
Alion🦁
yeah, right
Alion🦁
do i have to sen photo or i can send like message?
Alion🦁
@coincards It is my solution. I understood like this. If i am wrong correct me, please #include <stdio.h> int main(){ int v1[5]={1,2,3,4,5},v2[5]={1,2,3,4,5},v3=0,temp=0; for(int i = 0 ; i <=4; i++){ temp=v1[i] + v2[i]; v3+=temp; } printf("%d \n",v3); }
Anonymous
function?
Anonymous
thanks for the answer. the problem is i have to solve it using a function while getting unknown size of array input.
Alion🦁
@coincards at first, try to fix the problem, after that, if it works, then try to improve it.
Alion🦁
now, we can seperate this to functions easily
Anonymous
yeah but thats the thing i cant do. cannot improve properly. i can get the answers by with using function and 1 user input array. for previous question of sum and avg of 1 array
Alion🦁
calculation error mate again
is error name about "out of index"?
Anonymous
nope ;/ a bigger calculation
Alion🦁
of course it will give an error, his solution makes only x`th index of the arrays
Alion🦁
nope ;/ a bigger calculation
🤔bigger calculation?
Alion🦁
can i see the error?
Anonymous
no errors, calculation is wrong
Alion🦁
oh, you mean, Bug))
Anonymous
:/ yeah
Anonymous
expected answer: 30 but getting 110
Alion🦁
🤷‍♂️just improve))
Alion🦁
if it works, means way is right, just control the rudder))
Saurav
Write a program where you will create a class employee where id i.e. e_id will be a private data member and name i.e. e_name, salary i.e. e_salary of employee will be public data members. Use function get() and print() will be member functions. Use the same name as above. Create array of objects and use write function to copy value of 5 employees to a file i.e employee.dat and read function to print the value in a program.
Anonymous
why
44.0 is called real constant a real constant in c language always be cobsumed double datatype it means 8 bytes
Alion🦁
what will the output? int x; x = sizeof('a'); printf("%d", x); the output is 4 but it should be 1
Definitely, NO! Yeah, you're right it uses 1 byte. But, his size in memory is 4bytes. Because, when you declared it, you wrote "int", and "int" *holds* 4bytes in ram.(memory)
Alion🦁
yeah, if you're working with 0 and 1 maybe 😂