i want to print variable number of # for making a pattern like this:
#
##
###
####
but the code I am using is not working correctly.....Here's what I wrote for the first time:
#include<stdio.h>
void main()
{ int i;
for(i=1;i<=4;i++)
printf("%*c",i,'#');
}
And the output was:
#
#
#
#
then I tried to replace printf("%*c",i,'#'); with printf("%.*s",i,"#"); but it still didn't work.... this time the output was:
#
#
#
#
note: I want to do it with printf() only and not with the nested loop method because i want to make some other pattern which contains this part.... so if this one is clear to me then I would be able to make that pattern.....
Aucun commentaire:
Enregistrer un commentaire