IITDU Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Interesting C number pattern

Go down

number - Interesting C number pattern  Empty Interesting C number pattern

Post by BIT0112-Rokon Wed Jul 28, 2010 7:39 am

Guys,
If you are interested in C programming, this post really for you...
Here I'm going to share a link basically. Here you will found lots of solved problem with explanation. Hope you'll enjoy it.

It's a blog edited by one of my friend who lives in India. His name is Sridhar Jammalamadaka. He is a professional blogger from Pune. He is an experienced programmer
with expertise in Java, C and Micro Controller programming. By the way, you will find there some interesting post, like
1. different C question and and answer with explanation
2. C solved program
3. C puzzle

and additionally you can find educational material related to Jobs and Interviews. You
can also find technical articles on Software technologies such as C
language, Java and Flex.
this blog is very much helpful for IT freshers.

So guys, Have a look ...

CLICK HERE

Lets see a pattern -
Code:

#include

int main(void) {
 int i, j, k, s, p, q, sp, r, c = 1, nos = 13;
 for (i = 1; c <= 4; i++) {
  if ((i % 2) != 0) {  // Filters out the even line nos.
  for (j = 1; j <= i; j++) { // The upper left triangle
    printf("%2d", i);
  }
  for (s = nos; s >= 1; s--) {  // The spacing factor
    printf("  ");
  }
  for (k = 1; k <= i; k++) { // The upper right triangle
    printf("%2d", i);
  }
  printf("\n");
  nos = nos - 4;  // Space control
  ++c;
  }
 }
 nos = 10;  // Space control re intialized
 c = 1;
 for (p = 5; (c < 4 && p != 0); p--) {
  if ((p % 2) != 0) {  // Filters out the even row nos
  for (q = 1; q <= p; q++) {  // Lower left triangle
    printf("%2d", p);
  }
  for (sp = nos; sp >= 1; sp--) { // Spacing factor
    printf(" ");
  }
  for (r = 1; r <= p; r++) {  // Lower right triangle
    printf("%2d", p);
  }

  printf("\n");
  --c;
  nos = nos + 8;  // Spacing control.
  }
 }

 return 0;


and output will be :
number - Interesting C number pattern  Screen10

Cheers !!
BIT0112-Rokon
BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

http://blog.codexplo.org

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum