943,740 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 405
  • C RSS
Mar 12th, 2009
0

pls help me....!!!

Expand Post »
i have to make one prg in c
that accept only odd number (no) which is (4>no>30) & have to
genrate the pertern which is given below

when no=7 then given petern should be genrated


for that i have do some coding but i can't get the exatly petern..

pls help to solve this problem

thanx in advance .....

  1.  
  2.  
  3.  
  4. #include<stdio.h>
  5. #include<conio.h>
  6.  
  7. void main()
  8. {
  9. int no,i,j,no1;
  10. clrscr();
  11.  
  12. printf("Enter Number Of Lines: ");
  13. scanf("%d",&no);
  14.  
  15. no1=no/2;
  16.  
  17. for(i=1;i<=no1;i++)
  18. {
  19. for(j=i;j<no;j++)
  20. printf(" ");
  21.  
  22. for(j=1;j<=i;j++)
  23. {
  24. if(j==1 || j==i)
  25. printf("* ");
  26.  
  27. else
  28. printf(" ");
  29. }
  30. printf("\n");
  31. }
  32. for(i=1;i<=no*2-1;i++)
  33. printf("*");
  34.  
  35. for(i=1;i<=no;i++)
  36. {
  37. if(i%2==0)
  38. {
  39. for(j=1;j<=i;j++)
  40. {
  41. //printf("*");
  42. }
  43.  
  44. }
  45. else
  46. printf("\n");
  47. }
  48.  
  49.  
  50. for(i=1;i<=no*2-1;i++)
  51. printf("*");
  52. printf("\n");
  53.  
  54. for(i=no1;i>0;i--)
  55. {
  56. for(j=i;j<no;j++)
  57. printf(" ");
  58.  
  59. for(j=1;j<=i;j++)
  60. {
  61. if(j==1 || j==i)
  62. printf("* ");
  63.  
  64. else
  65. printf(" ");
  66. }
  67. printf("\n");
  68. }
  69.  
  70. getch();
  71. }
Attached Thumbnails
Click image for larger version

Name:	star.JPG
Views:	12
Size:	8.2 KB
ID:	9460  
Last edited by nitu_thakkar; Mar 12th, 2009 at 1:31 pm. Reason: pertern wes not proper formated
Similar Threads
Reputation Points: 0
Solved Threads: 1
Light Poster
nitu_thakkar is offline Offline
25 posts
since Jan 2009
Mar 12th, 2009
0

Re: pls help me....!!!

Hi,
I had som difficulties understanding what you wanted but I think I got it now.

You want draw a star with an uneven number of points using stdoutput?

Do you use some special algorithm for drawing the star,
or is that your problem?
Reputation Points: 70
Solved Threads: 9
Junior Poster
monkey_king is offline Offline
160 posts
since Aug 2008
Mar 15th, 2009
0

Re: pls help me....!!!

@monkey_king
( thnax for ur reply )


my pertern should be look like when i give

no=7

then out put is look like

http://img353.imageshack.us/img353/8527/starj.jpg
Last edited by nitu_thakkar; Mar 15th, 2009 at 2:23 pm.
Reputation Points: 0
Solved Threads: 1
Light Poster
nitu_thakkar is offline Offline
25 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Help needed!!!
Next Thread in C Forum Timeline: Problems reading multible words from a line of a file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC