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()?
Anonymous
Anonymous
how can add multiple subject values for each student?
Mar!o
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
András
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
András
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🦁
if i am wrong correct me
András
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.
András
Asad
Anonymous
thanks my g
Anonymous
also are there any unnecessary variable declarations ?
Anonymous
thanks both of u :)🙏🏼
András
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
Alion🦁
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
Anonymous
Anonymous
nope ;/ a bigger calculation
Alion🦁
of course it will give an error, his solution makes only x`th index of the arrays
Alion🦁
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.
klimi
I_Interface
Anonymous
why
44.0 is called real constant a real constant in c language always be cobsumed double datatype it means 8 bytes
Anonymous
Alion🦁
Alion🦁
yeah, if you're working with 0 and 1 maybe 😂
Anonymous