Say your variables are $x_1,\ldots, x_n$. The first constraint could be modeled as $$\sum_{i=1}^n x_i \leq C.$$ This makes sure that not more than $C$ variables are chosen.
If understood your question correctly the optimal solution may only have non-zero values for variables in the same group and not all variables from the group are mandatory to be selected.This can modeled as follows:
Let $\mathcal{G}$ be the set of groups. For each group $G \in \mathcal{G}$ you add a new variable $z_G \in \{0,1\}$ which indicates whether or not the group is picked. By adding the constraint $$\sum_{G\in\mathcal{G}} z_G \leq 1$$ you ensure that only 1 group makes it to the optimal solution.
Let $s_G$ indicate the number of variables in group $G$. The constraints $$\sum_{i \in G} x_i \leq z_G \cdot s_G ~\forall G \in \mathcal{G}$$
enforce that variables can only be chosen if the corresponding $z_G$ is equal to 1. The previous constraint, however, makes sure that this will only be the case for a single group.
Alternatively, you can (following fontanf's comment below) replace these constraints by a non-aggregated version: $$x_i\leq z_G ~~ \forall G \in \mathcal{G}, i\in G$$
If only one group has to be picked and the optimal solution would additionally require that all variables belonging to that group are chosen, then it would already suffice to set them equal to each other:
$$x_1=\ldots=x_l, ~ (1,\ldots,l)\in \mathcal{G}.$$
Typically, the non-aggregated constraints will result in a better relaxation.
In this case the presolve would eliminate all but one representative of each group automatically. But if I understood your question correctly not all variables of a group have to be picked. This can be modeled by the other two sets of constraints mentioned above.