+ 5

Who can explain this code to me please?

Const char* m[] ={"familyone", "familytwo", "familythree", "familyfour" , "familyfive"} ; Const char* n[] ={"boys", "girls"} ; Int tab[100],i,j; For(i=0;i<5;i++) { Printf(" Enter how many boys and girls in %s : ", m[i]) ; For(j=0;j<2;j++) { Printf("\n %s : ", n[j]) ; Scanf ("%d", &tab[i]) ; } } I wanna know what's the output! For example in tab[0] I will get the number of boys of first family?

11th Aug 2018, 5:05 PM
Ali Missaoui
Ali Missaoui - avatar
9 Answers
+ 1
ALi Missaoui I don't think it will output what you have expected... your scanf is inside j loop which is going to execute twice for boys nd girls for each of i ....
11th Aug 2018, 5:31 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 4
After I enter all the numbers, I will get the number of boys of first family in tab[0]?
11th Aug 2018, 5:31 PM
Ali Missaoui
Ali Missaoui - avatar
+ 4
Ketan Lalcheta thanks man I was about to tag you to answer me and hopefully you did thanks!
11th Aug 2018, 5:35 PM
Ali Missaoui
Ali Missaoui - avatar
+ 3
This is more clear I think : Const char* m[] ={"familyone", "familytwo", "familythree", "familyfour" , "familyfive"} ; Const char* n[] ={"boys", "girls"} ; Int tab[100][50],i,j; For(i=0;i<5;i++) { Printf(" Enter how many boys and girls in %s : ", m[i]) ; For(j=0;j<2;j++) { Printf("\n %s : ", n[j]) ; Scanf ("%d", &tab[i][j] ) ; } } Now tab[0][0] => number boys for family 1 Tab[0][1] => number girls for family 1 Tab[1][0] => number boys for family 2 Tab[1][1] => number girls for family 2 . . . ...
11th Aug 2018, 8:02 PM
Ali Missaoui
Ali Missaoui - avatar
+ 2
happy to help
11th Aug 2018, 5:37 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
You first have to enter the number of boys and girls then you can output them.
11th Aug 2018, 5:28 PM
B K
+ 1
yes, 2d array is better choice for this purpose...
12th Aug 2018, 5:18 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
dsdhugdmlplqb no
23rd Sep 2018, 1:45 AM
Yamile
0
first of all , there are many errors like first letter are capital and then , output : //I will not include printf statements... familyone boys : 3 // this is my input girls : 5 // this is my another input familytwo boys : 5 girls : 6 . . . . till familyfive boys : 8 girls : 8 that's it. thank you.
28th Oct 2018, 10:28 AM
Bipin Tatkare
Bipin Tatkare - avatar