Binary Numbers Pyramid : C Program

Computer Science » C Program » Binary Numbers Pyramid 

Program :

#include<stdio.h>
 
int main() 
{
   int i, j;
   int count = 1;
 
   for (i = 1; i <= 5; i++) 
   {
      printf("n");
      for (j = 1; j <= i; j++) 
      {
         printf("%d", count % 2);
         count++;
      }
 
      if (i % 2 == 0)
         count = 1;
      else
         count = 0;
   }
   return(0);
}

Output :

1
01
101
0101
10101
Subject Name : Computer Science
Exam Name : IIT GATE, UPSC ESE, RRB, SSC, DMRC, NMRC, BSNL, DRDO, ISRO, BARC, NIELIT
Posts Name : Assistant Engineer, Management Trainee, Junior Engineer, Technical Assistant
Computer Science Books

GATE 2023 Total InfoENGG DIPLOMAUGC NET Total Info
IES 2023 Total InfoPSUs 2022 Total InfoCSIR UGC NET Total Info
JAM 2023 Total InfoM TECH 2023 Total InfoRAILWAY 2022 Total Info

Related Posts

  • 1-10 Numbers in Pyramid : C ProgramComputer Science » C Program » 1-10 Numbers in Pyramid Program : [php]#include<stdio.h> int main() { int i, j; int count = 1; for (i = 0; i <= 4; i++) { printf("n"); for (j = 0; j < i; j++) { printf("%dt", count); count++; } } return(0); }[/php] Output : [php]1 2 3 4 5 6 7 8 9 10 [/php]
    Tags: program, numbers, pyramid, computer, science, output, programs
  • Rectangle using Line and Special Symbols : C ProgramComputer Science » C Program » Rectangle using Line and Special Symbols Program : [php]#include<stdio.h> int main() { int i, j; for (i = 0; i < 10; i++) { printf("n"); for (j = 0; j < 10; j++) { if (i == 0 || i == 9 || j == 0 || j == 9) printf("▲"); else printf("-"); } } return (0); }[/php] Output : [php]▲▲▲▲▲▲▲▲▲▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲▲▲▲▲▲▲▲▲▲[/php]
    Tags: program, computer, science, output, programs
  • Find Factorial of a Number : C ProgramComputer Science » C Program » Find Factorial of a Number Program : [php]#include <stdio.h> int main() { int i, fact = 1, num; printf("Enter the number : "); scanf("%d", &num); if (num <= 0) fact = 1; else { for (i = 1; i <= num; i++) { fact = fact * i; } } printf("nFactorial of %d is : %5d", num, fact); }[/php] Output : [php]Enter the number : 5 Factorial of 5 is : 120[/php]
    Tags: program, computer, science, output, programs
  • Print All Prime Numbers between 1 and 100 : C ProgramComputer Science » C Program » Print All Prime Numbers between 1 and 100 Program : [php]#include <stdio.h> int main() { int number,j,flag; printf(" The prime numbers between 1 and 100 : n"); for(number=2;number<=100;number++) { flag=0; for(j=2;j<=number/2;j++) { if(number % j == 0) { flag = 1; break; } } if(flag==0) printf("n %d ",number); } return 0; }[/php] Output : [php]The prime numbers between 1 and 100 : 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 [/php]
    Tags: program, numbers, computer, science, output, programs
  • Check if Number is Odd or Even : C ProgramComputer Science » C Program » Check if Number is Odd or Even Program : [php]#include<stdio.h> int main() { int n; printf("nEnter a number : "); scanf("%d",&n); if ( n%2 == 0 ) printf("n%d is an even number.", n); else printf("n%d is an odd number.", n); return 0; }[/php] Output 1: [php]Enter an number : 122 122 is an even number.[/php] Output 2: [php]Enter an number : 123 123 is an odd number.[/php]
    Tags: program, output, computer, science, programs

LEAVE A REPLY

Please enter your comment!
Please enter your name here