about structure | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

about structure

https://code.sololearn.com/cVXYBjH91u3r/#c i could add names and print it, but couldnt to for age and height. so correct my code. and tell where i have made mistakes

22nd Mar 2020, 6:01 AM
Reiner
Reiner - avatar
7 Answers
+ 1
22nd Mar 2020, 6:19 AM
Noman S. Shiekh
Noman S. Shiekh - avatar
+ 1
You have an array with 10 elements, valid index for an array with 10 elements are from 0 up to 9. In your code, you start saving data from index 1 to <n>. This means the first element is not getting any data. And it can cause problem when <n> is greater or equal to 10, because your array only has 10 elements. Just letting you know ...
22nd Mar 2020, 7:04 AM
Ipang
0
May i ask you,what is your input? and expected output please
22nd Mar 2020, 6:06 AM
Noman S. Shiekh
Noman S. Shiekh - avatar
0
input: number of entries for different persons eq-im gonna store and display 2 entries 1. name: raja age:35 height:6.1 2. name: rakesh age:40 height:5.5 then display it in the same order
22nd Mar 2020, 6:09 AM
Reiner
Reiner - avatar
0
yes 1 min i am testing it
22nd Mar 2020, 6:10 AM
Noman S. Shiekh
Noman S. Shiekh - avatar
0
i found the solution printf("Enter his/hers age: "); scanf("%d",temp[i].age);// scanf("%d",&temp[i].age); printf("Enter his/hers height: "); scanf("%f",temp[i].height);// scanf("%f",&temp[i].height); i forget to add '&' symbol in scanf thanks for your help
22nd Mar 2020, 6:17 AM
Reiner
Reiner - avatar
0
yes..obviouly
22nd Mar 2020, 6:19 AM
Noman S. Shiekh
Noman S. Shiekh - avatar