Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-10-2007, 03:13 PM
Minky Minky is offline
Newbie
 
Join Date: Sep 2007
Posts: 2
Rep Power: 0
Minky is on a distinguished road
Default Simple C problem

Hi, I am kind of new to C and I have run into some basic problems. I am trying to create a diamond in asterixes and I’ve managed to create a filled diamond with asterixes. But the problem I have is that I need it to look something like this:
Code:
     
             *
            * *
          *     *
         *      *
          *    *
           *  *
             *
The code that I managed to make looks like this:
Code:
#include <stdio.h>
#include <stdlib.h>

void pyramid(){
     int bredd,center,a,b,c;
	
	 printf("Lines: ");
	 scanf("%d",&bredd);
	 if(bredd%2!=0){ //Check if enterd number is odd or not

	 center = (bredd/2 + bredd%2);
	
	 for(a=1;a<=bredd;a+=2)
	 {	
		for(c=0;c<=center;c++)
			printf(" ");
		for(b=0;b<a;b++)
			printf("*");
		printf("\n");
		center--;
	}
	center+=2;
	for(a-=4;a>=1;a-=2)
	{
		for(c=center;c>=0;c--)
			printf(" ");
		for(b=0;b<a;b++)
			printf("*");
		printf("\n");
		center++;
	}
 }
 else{
      printf("Fel!\n");
      }
}
int main(void)
{
  pyramid();
  system("PAUSE");	
  return 0;
}
Any feedback would be appreciated!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-11-2007, 10:36 AM
Minky Minky is offline
Newbie
 
Join Date: Sep 2007
Posts: 2
Rep Power: 0
Minky is on a distinguished road
Default

I've solved it, so no need for help anymore, thank you!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Peculiar UI Problem Needs Tackling adriyel C# Programming 2 04-06-2008 08:46 AM
i have a problem please help me!!!???? stack Java Help 8 09-22-2007 04:17 PM
[C] Comparison problem Alhazred C and C++ 1 08-29-2007 05:58 AM
Delphi Sockets : Simple client and server program tosh5457 Pascal/Delphi 0 05-26-2007 12:00 PM
null exception problem connor7777 C# Programming 2 03-28-2007 12:37 PM


All times are GMT -5. The time now is 06:57 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads