Sunday, August 2, 2009

Turbo C program?

hey guyz.. please do help me to program this using for loop in turbo C.





1.


*


**


***


****


*****





this would be the output.. wht are the codes?

Turbo C program?
# include %26lt;conio.h%26gt;


int i,j;


main()


{


for (i=0; i%26lt;=5; i++)


{


for (j=i; j%26gt;0; j--)


printf ("*");


printf("\n");


}


getch();


return 0;


}
Reply:i=0;


j-0;


a ="*";


for i=0; i%26lt;5; i++


{for j=0; j%26lt;i+1; j++


{print a } }





Note: above is the psuedo code
Reply:cout is c++ -- LOL


try:


printf("+"); //do n times
Reply:# include %26lt;conio.h%26gt;


int i,j,x;


main()


{


clrscr();


printf ("enter number of blah blah");


scanf("%d", %26amp;x);


for (i=0; i%26lt;=x; i++)


{


for (j=i; j%26gt;0; j--)


printf ("*");


printf("\n");


}


getch();


return 0;


}
Reply:Try the flowing code in the Turbo C window





# include %26lt;conio.h%26gt;


int i,j;


main()


{


clrscr();


printf ("The Stars");


for (i=0; i%26lt;=5; i++)


{


for (j=i; j%26gt;0; j--)


printf ("*");


printf("\n");


}


getch();


return 0;


}
Reply:#include %26lt;iostream%26gt;


using namespace std;





int main(){


for(int c=1;c%26lt;6;c++){


for(int n=c;n%26gt;0;n--){


cout%26lt;%26lt;'*';


}


cout%26lt;%26lt;'\n';


}


return 0;


}


No comments:

Post a Comment