हेल्लो दोस्तों आज के इस पोस्ट आज के इस पोस्ट में आपको c program in hindi के बारे में आपको बताया जा रहा है तो चलिए शुरू करते है
1.pattern
#include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); for(i=1;i<=5;i++) { for(j=1;j<=5;j++) { printf("*"); // put any character } printf("\n"); } getch(); }
output
2.pattern
#include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); for(i=1;i<=5;i++) { for(j=1;j<=i;j++) { printf("*");//put any character } printf("\n"); } getch(); }
3.pattern
#include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); for(i=1;i<=5;i++) { for(j=5;j>=i;j--) { printf("*");//put any character } printf("\n"); } getch(); }
#include<stdio.h> #include<conio.h> void main() { int n=5; // size int i,j,k; clrscr(); for(i=1;i<=n;i++) { for(j=n-1;j>=i;j--) { printf(" "); } for(k=1;k<=i;k++) { printf("*"); } printf("\n"); } getch(); }
#include <stdio.h> #include<conio.h> void main() { int n=5;//size int i,j; clrscr(); for(i=1;i<=n;i++) { for(j=n;j>=1;j--) { if(i>=j) printf("*"); else printf(" "); } printf("\n"); } getch(); }
#include<stdio.h> #include<conio.h> void main() { int n=5; // size (max stars) int i,j,k; clrscr(); for(i=n;i>=1;i--) { for(j=n-1;j>=i;j--) { printf(" "); } for(k=1;k<=i;k++) { printf("*"); } printf("\n"); } getch(); }
#include <stdio.h> #include<conio.h> void main() { int n=5;//size int i,j; clrscr(); for(i=n;i>=1;i--) { for(j=n;j>=1;j--) { if(i>=j) printf("*"); else printf(" "); } printf("\n"); } getch(); }
#include<stdio.h> int main() { int min_stars=1; /* change value of min_stars to set min. no. of stars in piramid take odd no. for odd no. of stars in each row 1-3-5 etc take even no. for even no. stars in each row, 2-4-6 etc */ int p_height=5; //change value to increase or decrease the size of piramid int p_space=p_height-1; int i,j,k; for(i=0;i<p_height;i++) { for(j=p_space;j>i;j--) { printf(" "); } for(k=0;k<min_stars;k++) { printf("*"); } min_stars+=2; printf("\n"); } }
#include <stdio.h> int main() { int n = 5; // size int px = n; // left print control int py = n; // right print control int i,j; // loop var for(i = 1; i <= n; i++) { for(j = 1; j < n*2; j++) { if (j>=px && j<=py) { printf("*"); } else { printf(" "); } } px--; py++; printf("\n"); } return 0; }
#include<stdio.h> int main() { int p_height=4; //change value to increase or decrease the size of piramid int max_stars=p_height*2-1; int p_space=p_height-1; int i,j,k; for (i=p_height; i>=1; i--) { for (j=p_space; j>=i; j--) { printf(" "); } for (k=1; k<=max_stars; k++) { printf("*"); } max_stars-=2; printf("\n"); } return 0; }
#include <stdio.h> int main() { int n = 4; // size int px = 1; // print controls int py = n*2-1; int i,j; // loop var for (i = 1; i <= n; i++) { for (j = 1; j < n*2; j++) { if (j>=px && j<=py) { printf("*"); } else { printf(" "); } } px++; py--; printf("\n"); } return 0; }
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int size=3; int i,j; clrscr(); for(i=size;i>=-size;i--){ for(j=size;j>=abs(i);j--) { printf("*"); } printf("\n"); } getch(); }
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int size=3; int i,j,k; clrscr(); for(i=size;i>=-size;i--){ for(j=1;j<=abs(i);j++) { printf(" "); } for(k=size;k>=abs(i);k--) { printf("*"); } printf("\n"); } getch(); }
#include <stdio.h> #include <conio.h> int main() { int i,j,k; int p_height=5; for(i=1; i<=p_height; i++) { for(k=p_height-1; k>=i; k--) { printf(" "); } for(j=1; j<=i; j++) { printf("* "); // space after '*' } printf("\n"); } return 0; }
#include <stdio.h> #include<conio.h> void main() { int n=5;//size int i,j; clrscr(); for(i=1;i<=n;i++) { for(j=n;j>=1;j--) { if(i>=j) printf("* "); // space after '*' else printf(" "); } printf("\n"); } getch(); }
#include <stdio.h> int main() { int i,j,k; int p_height=5; for(i=p_height; i>=1; i--) { for(k=p_height-1; k>=i; k--) { printf(" "); } for(j=i; j>=1; j--) { printf("* "); // space after '*' } printf("\n"); } return 0; }
#include <stdio.h> #include<conio.h> void main() { int n=5;//size int i,j; clrscr(); for(i=n;i>=1;i--) { for(j=n;j>=1;j--) { if(i>=j) printf("* "); // space after '*' else printf(" "); } printf("\n"); } getch(); }
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int size=3; int i,j,k; clrscr(); for(i=size;i>=-size;i--){ for(j=1;j<=abs(i);j++) { printf(" "); } for(k=size;k>=abs(i);k--) { printf("* "); } printf("\n"); } getch(); }
#include <stdio.h> int main() { int n = 5; // size int px = n; // print controls int py = n; int i,j; // loop var for(i = 1; i <= n; i++) { for(j = 1; j <= n*2; j++) { if (j == px || j == py ) { printf("*"); } else { printf(" "); } } px--; py++; printf("\n"); } return 0; }
#include <stdio.h> int main() { int n = 5; // size int px = 1; // print controls int py = n*2-1; int i,j; // loop var for(i = 1; i <= n; i++) { for(j = 1; j <= n*2; j++) { if (j == px || j == py ) { printf("*"); } else { printf(" "); } } px++; py--; printf("\n"); } return 0; }
#include <stdio.h> int main() { int n = 9; // size int px = n/2+1; // print controls (mid) int i,j; // loop var for(i = 1; i <= n; i++) { for(j = 1; j <= n; j++) { if (j == px || j == n-px+1 ) { printf("*"); } else { printf(" "); } } if(i <= n/2) px--; else px++; printf("\n"); } return 0; }
#include <stdio.h> int main() { int n = 5; // size int px = n; int py = n; int i,j; for(i = 1; i <= n; i++) { for(j = 1; j < n*2; j++) { if (j>px && j<py) { printf(" "); } else { printf("*"); } } px--; py++; printf("\n"); } return 0; }
#include <stdio.h>
int main()
{
int n = 5; // size
int i,j;
for(i = 1; i <= n; i++)
{
for(j = 1; j < n*2; j++)
{
if (j<=i || j>= n*2-i)
{
printf(“*”);
}
else
{
printf(” “);
}
}
printf(“\n”);
}
return 0;
}
#include <stdio.h>
int main()
{
int n = 7; // size
int i,j;
int px=1;
for(i = 1; i <= n; i++)
{
for(j = 1; j <= n; j++)
{
if (j<=px || j>= n-px+1)
{
printf(“*”);
}
else
{
printf(” “);
}
}
if(i<= n/2)
px++;
else
px–;
printf(“\n”);
}
return 0;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int min_stars=1; /*change value to set min. no. of stars
in piramid
take odd no. for odd no. of stars in each row 1-3-5 etc
take even no. for even no. stars in each row, 2-4-6 etc
*/
int p_height=5; //change value to increase or decrease
the size of piramid
int p_space=p_height-1;
int i,j,k;
int n;
int x=1;
clrscr();
for(i=0;i<p_height;i++){
for(j=p_space;j>i;j–)
{
printf(” “);
}
for(k=0;k<min_stars;k++)
{
printf(“*”);
}
for(n=(p_height+p_height-2);n>=x;n–)
{
printf(” “);
}
for(k=0;k<min_stars;k++)
{
printf(“*”);
}
min_stars+=2;
x+=2;
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int p_height=5; //change value to increase or decrease
the size of piramid
int p_space=p_height-1;
int i,j,k;
int n;
int x=1;
clrscr();
for(i=0;i<p_height;i++){
for(j=p_space;j>i;j–)
{
printf(” “);
}
for(k=0;k<=i;k++)
{
printf(“* “);
}
for(n=(p_height+p_height-2);n>=x;n–)
{
printf(” “);
}
for(k=0;k<=i;k++)
{
printf(“* “);
}
x+=2;
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int p_height=5;
/*
change value of ‘p_height’ to increase or decrease the size
of pyramid
*/
int p_space=p_height-1;
int i,j,k;
int n;
int x=1;
clrscr();
/pyramid on top/
for(i=1; i<=p_height; i++)
{
/Broad Space/
for(n=1; n<=p_height; n++)
printf(” “);
for(k=p_space; k>=i; k–)
printf(” “);
for(j=1; j<=i; j++)
printf(“* “);
printf(“\n”);
}
/bottom pyramids/
for(i=0;i<p_height;i++){
for(j=p_space;j>i;j–)
{
printf(” “);
}
for(k=0;k<=i;k++)
{
printf(“* “);
}
for(n=(p_height+p_height-2);n>=x;n–)
{
printf(” “);
}
for(k=0;k<=i;k++)
{
printf(“* “);
}
x+=2;
printf(“\n”);
}
getch();
#include<stdio.h>
#include<conio.h>
void main()
{
int n=5; //size
int i,j;
clrscr();
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i==j||i+j==n+1)
printf(“*”);
else
printf(” “);
}
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n=5; //size
int i,j;
clrscr();
for(i=1;i<=n;i++){
for(j=1;j<=n;j++)
{
if(i==j)
printf(“o”);
else
printf(“x”);
}
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n=5; //size
int i,j;
clrscr();
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i<=j)
printf(“o”);
else
printf(“x”);
}
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n=5; //size
int i,j;
clrscr();
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i==j||i+j==n+1)
printf(“x”);
else
printf(“o”);
}
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i==3&&j==3)
printf(“o”);
else
printf(“x”);
}
printf(“\n”);
}
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
clrscr();
for(i=1; i<=5; i++)
{
for(j=1;j<=5;j++)
{
if(j==3||i==3)
printf(“* “);
else
printf(” “);
}
printf(“\n”);
}
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
clrscr();
for(i=1; i<=5; i++)
{
for(j=1;j<=5;j++)
{
if(j==3||i==3)
printf(“x “);
else
printf(“o “);
}
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int z=1;
int n=5; //size
int i,j,k;
clrscr();
for(i=0;i<n;i++){
for(j=n-1;j>i;j–)
{
printf(” “);
}
for(k=0;k<n;k++)
{
printf(“*”);
}
z++;
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,c,k;
clrscr();
/*logic one using 3 loops
for(i=4;i>=0;i-=2)
{
for(c=2;c>0;c–)
{
for(j=6;j>i;j–)
{
printf(“*”);
}
printf(“\n”);
}
} */
//logic two using if-else
for(i=1;i<=6;i++)
{
/*if(i%2!=0)
{
k=i+1;
}else
{
k=i;
}*/
k=(i%2!=0)?i+1:i; //conditional operator in replace of if-
else
for(j=0;j<k;j++)
{
printf(“*”);
}
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,c,k,g;
clrscr();
/*
// logic 1
for(i=4;i>=0;i-=2)
{
for(c=2;c>0;c–)
{
for(g=0;g<i;g++)
{
printf(” “);
}
for(j=6;j>i;j–)
{
printf(“*”);
}
printf(“\n”);
}
}
*/
//logic 2
for(i=1;i<=6;i++)
{
/*if(i%2!=0)
{
k=i+1;
}else
{
k=i;
}*/
k=(i%2!=0)?i+1:i; //using conditional operator in place
of if-else
for(g=6;g>k;g–)
{
printf(” “);
}
for(j=0;j<k;j++)
{
printf(“*”);
}
printf(“\n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n=6; //size
int i,j,c,k;
clrscr();
/*
// logic one (using 3 Loops)
for(i=n;i>0;i-=2)
{
for(c=2;c>0;c–)
{
for(j=0;j<i;j++)
{
printf(“*”);
}
printf(“\n”);
}
}
*/
// logic two (using if-else)
for(i=n;i>0;i–)
{
//if(i%2!=0) { k=i+1; } else { k=i; }
k=(i%2!=0)?i+1:i; //use of conditional operator instead of
if-else
for(j=0;j<k;j++)
{
printf(“*”);
}
printf(“\n”);
}
getch();
}
#include<stdio.h> #include<conio.h> void main() { int n=6; //size int i,j,c,k,x; clrscr(); /* // logic one (using Loops only) for(i=n;i>0;i-=2) { for(c=2;c>0;c--) { for(x=i;x<n;x++) { printf(" "); } for(j=0;j<i;j++) { printf("*"); } printf("\n"); } } */ // logic two (using if-else) for(i=n;i>0;i--) { //if(i%2!=0) { k=i+1; } else { k=i; } k=(i%2!=0)?i+1:i; //use of conditional operator instead of if-else for(x=k;x<n;x++) { printf(" "); } for(j=0;j<k;j++) { printf("*"); } printf("\n"); } getch(); }
#include<stdio.h> #include<conio.h> void main() { int n=3; //size int i,j,c; clrscr(); for(i=1;i<=n;i++) { for(c=n-1;c>0;c--) { for(j=0;j<i;j++) { printf("*"); } printf("\n"); } } getch(); }
reference-https://www.programiz.com/c-programming/examples
निवेदन-अगर आपको यह आर्टिकल अच्छा लगा हो तो आप इस पोस्ट को अपने दोस्तों के साथ जरुर शेयर(c program in hindi) करे और आपको जिस टॉपिक(c program in hindi) पर आपको पढना या नोट्स चाहिए तो हमें जरुर कमेंट() करे आपका कमेंट्स हमारे लिए बहु मूल्य है धन्यवाद