×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Sum of its Individual Digits Repeatedly - MAKAUT / WBUT MCA 2011 Differentiate between do-while and while statements WBUT MCA 2012
Write a c Programming to create a binary pyramid. - MAKAUT / WBUT MCA 2012 - C Language
1826    Arnab De    08/04/2020

Write a C program to print the above pyramid.

First analysis the pattern,

  1. each and every line start with 1.
  2. After printting each time value is inverse.
  3. Print [Total No. of row - current no of row] space before print any number
  4. Every row have [(row * 2) - 1] number of column.

softetechnologies
void main()
{
	int r,c,s,n=4,v=1;
	clrscr();
	for(r=1;r<=n;r++)
	{
		for(s=1;s<=n-r;s++)
		{
			printf(" ");
		}
		for(c=1;c<=(r*2)-1;c++)
		{
			printf("%d",v);
			v=!v; 	//	NOT Operation on v
					//	Inverse the value of v
		}
		printf("\n");
		v=1;
	}
	getch();
}
softetechnologies

Output:

pyramid Pattern C Programming
Sum of its Individual Digits Repeatedly - MAKAUT / WBUT MCA 2011 Differentiate between do-while and while statements WBUT MCA 2012
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Nelson Mandela
Education is the most powerful weapon which you can use to change the world.
Nelson Mandela
3095
81.13
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     54175
25/06/2018     45159
01/01/2018     43710
28/06/2017     41238
02/08/2017     40260
01/08/2017     34302
06/07/2017     34099
15/05/2017     33354
11/09/2018     30383
14/07/2017     29874
softetechnologies