[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

How do i write nested loops for producing somekind of patterns........using writePattern() function in C language..I have written the loop but is not working properly...

Asked by Sambho in C Programming Language, C# Programming Language, Programming Languages

Typical programme question is like this
                                                            ..............a program which prompts the user to enter an integer (in the range 1-8)determining picture size and then uses functions which call writePattern to draw each of the following pictures. (The examples illustrate size 4).

     *
      *
       *
        *

        *
       *
      *
     *

*     *
 *   *
  * *
   *
  * *
 *   *
*     *  

     *...
     **..
     ***.
     ****

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
#include<stdio.h>
 
#define BLANK ' '
 
 
void writePattern(char c1, char c2, char c3, char c4, char c5, int n1, int n2, int n3, int n4, int n5, int length);
void writeCharFixCount(char, int *, int *);
 
int main( void) {
    
    char mark = '*';
    char dot = '.';
    int i;
    int width, length;
    int size;
    int x = size;
    //length == size;
    //width == size;
    
    printf("Please enter an integer in the range 1-8 both inclusive: ");
    scanf("%d", &size);
    
       for( i = 1; i <= size; i++){
                     writePattern('*','.',BLANK,BLANK,BLANK,1, size-1,0,0,0, size); 
                       if (i = size-x)
                      writePattern( '*','.',BLANK, BLANK, BLANK, size-x,size-(size-x),0,0,0, size);
                       
                      if (i = size-1)
                      writePattern( '*','.',BLANK, BLANK, BLANK, size-1,size-(size-1),0,0,0, size);
                        if (i= size)
                      writePattern('*','.',BLANK,BLANK,BLANK,size, size- size ,0,0,0, size);  
                      }
                      
                      return 0;
                  }
                  
    void writePattern(char c1, char c2, char c3, char c4, char c5,
                  int n1,  int n2,  int n3,  int n4,  int n5, int length)  {
	 while ((n1 > 0) && (length > 0))
        	 writeCharFixCount(c1, &n1, &length);
 
	 while ((n2 > 0) && (length > 0))
		 writeCharFixCount(c2, &n2, &length);
 
	 while ((n3 > 0) && (length > 0))
		 writeCharFixCount(c3, &n3, &length);
 
	 while ((n4 > 0) && (length > 0))
		 writeCharFixCount(c4, &n4, &length);
 
	 while ((n5 > 0) && (length > 0))
		 writeCharFixCount(c5, &n5, &length);
 
	 printf("\n");   /* advance the cursor to the beginning of a new line */
}
 
void writeCharFixCount(char c, int *count1, int *count2)
/* writes one copy of character c and decrements count1 and count2 */  {
	 printf("%c", c);
	 (*count1)--;
	 (*count2)--;
}
[+][-]09/25/09 05:42 AM, ID: 25422348Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: C Programming Language, C# Programming Language, Programming Languages
Sign Up Now!
Solution Provided By: epasquier
Participating Experts: 2
Solution Grade: A
 
[+][-]09/25/09 05:58 AM, ID: 25422447Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/09 06:01 AM, ID: 25422462Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/09 06:09 AM, ID: 25422532Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/09 03:06 PM, ID: 25427657Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/09 05:04 PM, ID: 25428213Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/25/09 06:48 PM, ID: 25428452Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/25/09 11:00 PM, ID: 25428915Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625