Posts

Showing posts with the label programming

pattern printing in c/c++

Image
pattern printing in c/c++- ganesha pattern printing- #include<iostream>
using namespace std;

int main() {
    int n,star,space,i=0,row=1;
    cin>>n;
    star=(n/2)+1;
    space=(n/2)-1;
    for(row=1;row<=1;row++)
    {
        cout<<"*";
        for(i=1;i<=space;i++)
        {
            cout<<" ";
        }
        for(i=1;i<=star;i++)
        {
            cout<<"*";
        }
        cout<<endl;
    }
    while(row<=(n/2))
    {
      cout<<"*";
      for(i=1;i<=space;i++)
      {
          cout<<" ";

      }
      cout<<"*"<<endl;

        row++;
    }
    for(i=0;i<n;i++)
    {
        cout<<"*";
    }
    cout<<endl;
    int space1=space;
    space=space+1;
    while(row<n-1)
    {
    for(i=0;i<space;i++)
    {
        cout<<" ";
    }
    cout<<"*";
    for(i=0;i<space1;i++)
 …

how to print number triangle in c language : pattern printing

Image
how to print number  triangle in c language : pattern printing #include<stdio.h>
int main()
{
    int i,j,k;
    for(i=0;i<=5;i++)
   {


    for(j=0;j<=i;j++)
    {
        printf("%d",j);
   }
   printf("\n");
   }
   return 0;
}

output
doubt comment box mai puche
ask doubt in comment box.

pattern printing in c language

Image
print pattern in c language- #include<stdio.h>
int main()
{
int i,j,k;
for(i=0;i<=10;i++)
{

for(k=0;k<=i;k++)
{
printf("*");
}
for(j=0;j<=20-2*i;j++)
{
printf(" ");

}

for(k=0;k<=i;k++)
{
printf("*");
}
printf("\n");
}
for(i=0;i<10;i++)
{
    for(j=0;j<10-i;j++)
    {
printf("*");
    }
    for(k=0;k<=2*i+2;k++)
   { printf(" ");
   }
   for(int l=0;l<10-i;l++)
   {
       printf("*");
   }
   printf("\n");
}
return 0;
}

output- iss program ka output

pattern printing in c language using loop

Image
pattern printing in c language using loop
#include<stdio.h>

int main()

{

    int i,j,k;

    for(i=0;i<=5;i++)

   {





    for(j=0;j<=i;j++)

    {

        printf("%d",j);

   }
for(k=0;k<=10-(2*i);k++)
{
    printf(" ");
}
int l=i;
for(l=i;l>=0;l--)
{
    printf("%d",l);
    }
   printf("\n");

   }

   return 0;
}
output-

doubt comment box mai puche
ask doubt in comment box.

Programming in c

Image

how to print triangle using loop in c language

Image
how to print triangle using loop in c language iss question mai humko n hight aur n width ka ek right angle print krna hai
isske liye code niche lika gya hai iss code ko dhyan se smjne ki kosis kriye  #include<stdio.h> int again(int); /function declaration int main() { int i=0,n,k; /yaha n height aur width k k liye use kiya gya hai scanf("%d",&n); /triangle ki height aur width k=n; / k mai n ki value assign kri gyi hai for(i=0;i<=k;i++) { n=again(n);/humne ek again naam ka function bnaya hai }

return0; }
int again(int n)/function definition { int i=0; for(i=0;i<=n;i++) { printf("*"); } printf("\n"); n--; return n; }

print fibonacii series using array in c language

Image
print Fibonacci series using array in c language
kya hoti hai fibonacii series- aise series jisme agla term pichle do term k sum se bna hota hai jaise 0,1,1,2,3,5............ is series mai phla term 0 hai aur dusra 1 to 3rd term 0+1=1,4th term=third+second term=1+1=2 aise hi ye series aage badte rhaegi.

#include<stdio.h>
int main()
{
int k=2,a[k],n;
scanf("%d%d%d",&n,&a[0],&a[1]);     /*yaha n number of term hai jaha tk aap series print krwanna                                                                                   chahte ha a0 and a1 series k phle aur dusre term i*/
printf("first %d term of fibonacii series is ",n);
printf("%d %d",a[0],a[1]);
for(k=2;k<n;k++)
{
a[k]=a[k-1]+a[k-2];
printf(" %d",a[k]);
}
return 0;
}

find factorial of any number using recursion in c

factorial of any number using recursion in c c language mai recursion ka us krke kisi number ka factorial  #include<stdio.h>           //header file
int fac(int);                     //function definition
void main()                   //main function
{int a,s;                           //main k under k variable
scanf("%d",&a);           //input number by user
s=fac(a);                       // value assigned in s
printf("%d",s);            //s ki final value jo factorial k baad niklegi
}

int fac(int x)                  //fac() function ka declaration
{ if(x==0)
return 1;
x=x*fac(x-1);
return x;
}

c language question print the series of all prime no till N

Q-1 print  the series of all prime no till N
#include <stdio.h> int main() { int prime(int); int a; scanf("%d",&a); while(a>=2) { prime(a); a--; } return 0; } int prime(int x) { int i=2; for(i=2;i<=x-1;i++) { if(x%i==0) { return 0; } } if(x==2) { printf("%d",x); return 0; } if(i==x) { printf(" %d",x); return 0; } }

c programming/ for loop in c

Image
c# programming
for loop in c





Loop in c language- c# programming
C language mai jab kise statement ko humbaar baar reapeat krwana chate hai to uske liyeloop ka use kiyajata hai Loop ek type ka action statement hai C language mai 3 type k loop hote hai
1-While loop 2-Do while  loop
3-For loop Chalo ab while loop ko example se se smjhte hai:- Agar mai apnenaam ko screen pe 5 baar print krwana chahta hu to mujhe ya to 5 baar printf function ka use krna padega ya 5 baar apna naam likhna padega
But agar mai baar baar likhne se bachana chahta hu toh loop ka use krte hai main() { Int x; clrscr(); scanf(“%d”,&x); while(5>x) //yaha bracket k under condition likhi jati hai agar ye condition true ho to while loopka block chalega agar false ho to nhi chalega yaha maine likha hai ki agar enter kiya gya no 5 se chota hai to while ka box chalao nhi to mat chalao ek baar while ka box chal jaye to condition fir se check kri jayegi agar fir se dobara condition sh…