+ 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?
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 ....
+ 4
After I enter all the numbers, I will get the number of boys of first family in tab[0]?
+ 4
Ketan Lalcheta thanks man I was about to tag you to answer me and hopefully you did thanks!
+ 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
.
.
.
...
+ 2
happy to help
+ 1
You first have to enter the number of boys and girls then you can output them.
+ 1
yes, 2d array is better choice for this purpose...
0
dsdhugdmlplqb
no
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.