C (programming language) DEFFINATION

C (pronounced like the letter C) is a general-purpose computer programming language developed between
1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system
Although C was designed for implementing system software, it is also widely used for developing
portable application software.C has greatly influenced many other popular programming languages, most notably
C++, which began as an extension to C.

Wednesday, 5 October 2011

WRITE A PROGRAM IN c program to print patterns of numbers and stars


    *
   ***
  *****
 *******
*********
We have shown five rows above, in the program you will be asked to enter the numbers of rows you want to print in the pyramid of stars.

C code



#include<stdio.h>
#include<conio.h>
 
main()
{
   int row, c, n, temp;
 
   printf("Enter the number of rows in pyramid of stars you wish to see ");
   scanf("%d",&n);
 
   temp = n;
 
   for ( row = 1 ; row <= n ; row++ )
   {
      for ( c = 1 ; c < temp ; c++ )
         printf(" ");
 
      temp--;
 
      for ( c = 1 ; c <= 2*row - 1 ; c++ )
         printf("*");
 
      printf("\n");
   }
 
   getch();
   return 0;
}


Output:


stars pyramid
Consider the pattern
*
**
***
****
*****
to print above pattern see the code below:
#include<stdio.h>
 
main()
{
    int n, c, k;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    for ( c = 1 ; c <= n ; c++ )
    {
        for( k = 1 ; k <= c ; k++ )
            printf("*");
 
        printf("\n");
    }
 
    return 0;
}
12345
 1234
  123
   12
    1

#include<stdio.h>
 
main()
{
   int n, c, k, space;
 
   scanf("%d", &n);
 
   space = 0;
 
   for ( k = n ; k >= 1 ; k-- )
   {
       for ( c = 1 ; c <= space ; c++ )
       printf(" ");
 
       space++;
 
       for ( c = 1 ; c <= k ; c++)
          printf("%d", c);
 
       printf("\n");
   }
 
   return 0;
}



A B C D E F G H
 A B C D E F G
  A B C D E F 
   A B C D E
    A B C D 
     A B C
      A B
       A

#include<stdio.h>
 
main()
{
      char ch = 'A';
      int n, c, k, space = 0;
 
      scanf("%d", &n);
 
      for ( k = n ; k >= 1 ; k-- )
      {
          for ( c = 1 ; c <= space ; c++)
              printf(" ");
 
          space++;
 
          for ( c = 1 ; c <= k ; c++ )
          {
             printf("%c ", ch); 
             ch++;
          }
 
          printf("\n");
          ch = 'A';
      }
 
      return 0;
}

pr
pro
prog
progr
progra
program


#include<stdio.h>
#include<string.h>
 
main()
{
      char string[100];
      int c, k, length;
 
      printf("Enter a string\n");
      gets(string);
 
      length = strlen(string);
 
      for ( c = 0 ; c < length ; c++ )
      {
          for( k = 0 ; k <= c ; k++ )
          {
               printf("%c", string[k]);
          }
          printf("\n");
      }
 
      return 0;
}
1
121
12321
1234321
123454321

#include<stdio.h>
 
main()
{
      int n, c, k, x = 1;
 
      scanf("%d", &n);
 
      for ( c = 1 ; c <= n ; c++ )
      {
          for ( k = 1 ; k <= c ; k++ )
          {
              printf("%d", x);
              x++;
          }
 
          x--;
 
          for ( k = 1 ; k <= c - 1 ; k++ )
          {
              x--;
              printf("%d", x);
          }
 
          printf("\n");
          x = 1;
      }
 
      return 0;
}
1   1
12 21
12321

#include<iostream>
 
using namespace std;
 
main()
{
      int n, k, c, space, x, num = 1;
 
      cin >> n;
 
      x = n;
 
      for ( k = 1 ; k <= n ; k++ )
      {
          for ( c = 1 ; c <= k ; c++ )
          {
             cout << num;
             num++;
          }
 
          num--;
 
          for ( c = 1 ; c <= 2*x - 3 ; c++ )
              cout << " ";
 
          x--;
 
          if ( k != n )
          {
             for ( c = 1 ; c <= k  ; c++ )
             {
                cout << num;
                num--;
             }
          }
          else
          {
              num--;
              for ( c = 1 ; c <= k - 1 ; c++ )
              {
                 cout << num;
                 num--;
              }
          }
 
          printf("\n");
          num = 1;
      }    
 
      return 0;
}

        1
       232
      34543
     4567654
    567898765   

#include<stdio.h>
 
main()
{
      int n, c, d, num = 1, space;
 
      scanf("%d",&n);
 
      space = n - 1;
 
      for ( d = 1 ; d <= n ; d++ )
      {
          num = d;
 
          for ( c = 1 ; c <= space ; c++ )
              printf(" ");
 
          space--;
 
          for ( c = 1 ; c <= d ; c++ )
          {
              printf("%d", num);
              num++;
          }
          num--;
          num--;
          for ( c = 1 ; c < d ; c++)
          {
              printf("%d", num);
              num--;
          }
          printf("\n");
 
      }
 
      return 0;
}

#18 Guest : how to print this pattern

*******
***S***
**SSS**
*SSSSS*
where S represents Space
*******
*** ***
**   **
*     *


#include<stdio.h>
 
main()
{
    int n, c, k, space, r;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    space = 1;
    r = n-1;
 
    for( c = 1 ; c <= 2*n - 1 ; c++ )
         printf("*");
 
    printf("\n");
 
    for ( k = 2 ; k <= n ; k++ )
    {
 
        for( c = 1 ; c <= r ; c++ )
            printf("*");
 
        for ( c = 1 ; c <= space ; c++ )
            printf(" ");
 
        space = 2*k-1; 
 
        for( c = 1 ; c <= r ; c++ )
            printf("*");
        r--;
 
        printf("\n");
    }
 
    return 0;
}
    * 
   **
  ***
 ****
*****

#23 adminPs : star pattern source code


#include<stdio.h>
 
main()
{
    int n, c, k, space;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    space = n;
 
    for ( k = 1 ; k <= n ; k++ )
    {
        for ( c = 1 ; c < space ; c++ )
            printf(" ");
 
        space--; 
 
        for( c = 1 ; c <= k ; c++ )
            printf("*");
 
        printf("\n");
    }
 
    return 0;
}
1
22
333
4444
55555


#25 adminPs : number pattern source code


#include<stdio.h>
 
main()
{
    int n, c, k;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    for ( c = 1 ; c <= n ; c++ )
    {
        for( k = 1 ; k <= c ; k++ )
            printf("%d", c);
 
        printf("\n");
    }
 
    return 0;
}

*
**
***
****
***
**
*




#include<stdio.h>
 
main()
{
    int n, c, k;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    for ( c = 1 ; c <= n ; c++)
    {
        for ( k = 1 ; k <= c ; k++ )
            printf("*");
 
        printf("\n");
    }
 
    for ( c = n - 2 ; c >= 0 ; c-- )
    {
        for ( k = c ; k >= 0 ; k-- )
            printf("*");
 
        printf("\n");
    }
 
    return 0;
}
   *
  *A*
 *A*A*
*A*A*A*    

#31 adminPs : code to print pattern of stars and numbers


#include<stdio.h>
 
main()
{
    int n, c, k, space, count = 1;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    space = n;
 
    for ( c = 1 ; c <= n ; c++)
    {
        for( k = 1 ; k < space ; k++)
           printf(" ");
 
        for ( k = 1 ; k <= c ; k++)
        {
            printf("*");
 
            if ( c > 1 && count < c)
            {
                 printf("A");    
                 count++; 
            }      
        }    
 
        printf("\n");
        space--;
        count = 1;
    }
    return 0;
}
* * * * *
* * *
* *
*

#include<stdio.h>
 
main()
{
    int n, c, k, temp;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    temp = n;
 
    for ( c = 1 ; c <= n ; c++ )
    {
        for( k = 1 ; k <= temp ; k++ )
            printf("* ");
 
        temp--;
 
        printf("\n");
    }
 
    return 0;
}

*
* *
* * *
* * * *

#35 adminPs : code


#include<stdio.h>
 
main()
{
    int n, c, k;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    for ( c = 1 ; c <= n ; c++ )
    {
        for( k = 1 ; k <= c ; k++ )
            printf("* ");
 
        printf("\n");
    }
 
    return 0;
}

1
1 2
1 2 3
1 2 3 4

#include<stdio.h>
 
main()
{
    int number = 1, n, c, k;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    for ( c = 1 ; c <= n ; c++ )
    {
        for( k = 1 ; k <= c ; k++ )
        {
            printf("%d ", number);
            number++;
        }
 
        number = 1;
 
        printf("\n");
    }
 
    return 0;
}

#include<stdio.h>
 
main()
{
    int n, c, k;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    for ( c = 1 ; c <= n ; c++ )
    {
        for( k = 1 ; k <= c ; k++ )
            printf("%d ", k);
 
        printf("\n");
    }
 
    return 0;
}
      *
    *   *
  *   *   *
*   *   *   *
c code to print pattern

#include<stdio.h>
 
main()
{
    int n, c, k = 2, j;
 
    printf("Enter number of rows\n");
    scanf("%d",&n);
 
    for ( j = 1 ; j <= n ; j++ )
    {
        for ( c = 1 ; c <= 2*n-k ; c++)
           printf(" ");
 
        k = k + 2;
 
        for ( c = 1 ; c <= j ; c++)
           printf("*   ");
 
        printf("\n");
    } 
 
    getch();
    return 0;
}

242 comments:

«Oldest   ‹Older   1 – 200 of 242   Newer›   Newest»

i need a program to draw the below paterns.please help me soon.
1.1 1 1 1
0 0 0 0
1 1 1 1
0 0 0 0

2.1
2 1
3 2 1
4 3 2 1
5 4 3 2 1

3.1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

i need program for below pattern

10 8 6 4 2
10 8 6 4
10 8 6
10 8
10

I need program for below pattern

*****6
****656
***65456
**653456
*654323456
65432123456

These programs are so amazing and very useful to me.Thanks for posting this.

c code for
1
2 1
3 2 1
4 3 2 1

/*c program for number triangle pyramid*/
#include
#include
int main()
{
int num,c,r;
printf("Enter loop repeat number(rows): ");
scanf("%d",&num);
for(r=1; num>=r; r++)
{
for(c=r; c>=1; c--)
printf("%d",c);
printf("\n");
}
getch();
return 0;
}

/*************OUTPUT****************
Enter loop repeat number(rows): 5

1
21
321
4321
54321

c code for

1 2 3 4 5 5 4 3 2 1
1 2 3 4 4 3 2 1
1 2 3 3 2 1
1 2 2 1
1 1

c code for
1234554321
1234 4321
123 321
12 21
1 1

1
1 2 3
1 2 3 4 5
1 2 3
1

i need a program to print *
* *
* *
* *

78910
456
23
1
please give the code

to print
1
23
456





import java.util.*;
class A
{
int n;
void getval(int a)
{
n=a;
}
void print()
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
System.out.print(i);
System.out.println();

}
}
}
class patterndemo
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter value of n");
int a=sc.nextInt();
A ob=new A();
ob.getval(a);
ob.print();
}
}

program for pattern
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1

the codes really helped me

program to print
10001
01010
00100
01010
10001

printf("Fantastic!!!");


ADDICTED OF C LANGUAGE!!!

program to print

11111
12221
12321
12221
11111

ZXYWVWXYZ
ZYXWXYZ
ZYXYZ
ZYZ
Z
please I want c program for this pattern

This comment has been removed by the author.

........9
.......898
......78987
.....6789876
....567898765
...45678987654
..3456789876543
.234567898765432
12345678987654321

can u generate code for this pattern

This comment has been removed by the author.

11111
2222
333
22
1
how to print this code?(avesh vikram singh)

11111
2222
333
22
1
how to print this code?(avesh vikram singh)

1000
0100
0010
0001
how this will be print in c?

program to print
*
**
***
****
*
**
***
****

program to print
*
**
***
****
*
**
***
****

1
22
333
4444
55555
how to print this code in "c" language?

1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9


please any one send me the code to the above pattern to my mail id
sridhar.474@gmail.com

kya koi \ n " print kara sakta hai c me

COMPUTER
O E
M T
P U
U P
T M
E O
RETUPMOC

TO PRINT THE PATTERN BELOW

COMPUTER
O E
M T
P U
U P
T M
E O
RETUPMOC

how to print this pattern
1
121
1331
14441

how to print the following pattern
1 2 3 4 5 5 4 3 2 1
1 2 3 4 4 3 2 1
1 2 3 3 2 1
1 2 2 1
1 1

i want output like this....please tell me how to do it
4 4 4 4
3 3 3
2 2
1
2 2
3 3 3
4 4 4 4

how to print theese patterns plzzz help me ....
(1) 4321 (3) 4444
321 333
21 22
1 1

(2) 1234 (4) 1111
123 222
12 33
1 4
(5) 4321
432
43
4

1
1 2 3
1 2 3 4 5
1 2 3
1
i need a code for this .

1
1 2 3
1 2 3 4 5
1 2 3
1
i need a code for this .

1
1 2 3
1 2 3 4 5
1 2 3
1
i need a code for this .

1
2 1
3 2 1
4 3 2 1
5 4 3 2 1

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
How to print this one?

hii guys .....i need a pattern as follows:

4 3 2 1 2 3 4
3 3
2 2
1 1
2 2
3 3
4 3 2 1 2 3 4

you can get some of the above codes an a lot of other programs at :::

https://www.facebook.com/ITSagarSol

*** Share with Care ***

I need a program for the pattern
1
A B
1 2 3
A B C D
1 2 3 4 5

Output for the following program

ABCDEFGFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A

3
3 3
3 6 3
3 9 9 3
3 12 18 12 3


reply code this pattern

This comment has been removed by the author.
This comment has been removed by the author.
This comment has been removed by the author.

To print following pattern
10 8 6 4 2
10 8 6 4
10 8 6
10 8
10


#include
int main()
{
int a;
printf("Enter number which is digit first digit\n");
scanf("%d",&a);
int n=a;
for(int i=n-1; i>1; i--)
{
for(int j=1; j<=i; j++)
{
if(a%2==0)
{
printf("%d",a);
printf(" ");
}
a--;
}
printf("\n");
a=n;
}
return 0;
}
------------------------------
------------------------------
please include header file in
program because its not print
on blogger
------------------------------
------------------------------

--------*OUTPUT*--------------
Enter number which is your first digit
10

10 8 6 4 2
10 8 6 4
10 8 6
10 8
10

To print following pattern
1
22
333
4444
55555


#include
main()
{
int n,num=1;
printf("Enter how much you want to print\n");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
for(int j=1; j<=i; j++)
{
printf("%d",num);
}
num++;
printf("\n");
}
}

------------------------------------------------------
------------------------------------------------------
Please include header file in program
------------------------------------------------------
------------------------------------------------------


====================//*OUTPUT*//======================
How much long you want to print
5
1
22
333
4444
55555

how can i print this pattern without using if and else statement:

* * * * *
* * * *
* * *
* * * *
* * * * *

want to display the pattern :

*****
* *
* *
* *
*****

I Need code to print the pattern:
5
54
543
5432
54321

c code for
1
2 3
4 5 6
7 8 9 10 11

654321
54321
4321
321
21
1
i have this program

/* 10 8 6 4 2
10 8 6 4
10 8 6
10 8
10 */

#include
main()
{
int i,j,k;
for(i=1;i<=5;i++)
{


for(j=10,k=5-i+1;j>=2&&k>=1;j=j-2,k--)
{
printf("%d ",j);
}
printf("\n");
}
}

please include header file in program because its not included in blogger

/* *****6
****656
***65456
**6543456
*654323456
65432123456 */
#include
main()
{
int i,j,k;
for(i=1;i<=6;i++)
{
for(j=6-i;j>=1;j--)
{
printf("*");
}
for(j=6,k=i;j>=6+1-i&&k>=1;j--,k--)
{
printf("%d",j);
}
for(j=j+2,k=i;j<=6&&k>1;j++,k--) /*j comes as 1 less due to j-- so j=j+2 another
1 for the pattern */
{
printf("%d",j);
}


printf("\n");
}
}

/*1
23
456
78910 */

#include
main()
{
int i,j,k=0;
for(i=1;i<=4;i++)
{
for(j=i;j>=1;j--)
{
k++;
printf("%d",k);
}printf("\n");
}
}

/*1
AB
123
ABCD
12345 */
#include
main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
if(i%2==0)
{
printf("%c",64+j);
}
else{
printf("%d",j);
}
}printf("\n");
}
}

/*1
12
234
4567
7891011 */
#include
main()
{
int i,j,k=1;
for(i=1;i<=5;i++)
{

for(j=1;j<=i;j++)
{
printf("%d",k);
k++;
}k--;printf("\n");
}
}

plz give the code to make
123454321
1234 4321
123 321
12 21

Hello I want a normal Star printing program with counting total number of star
suppose line are 3
then pattern as :
*
**
***
total star= 6;
*******************
my program as:
static int count=0;
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
print("*");
count++;
}
print("\n");
}

I want some optimize code for it

_______________*
_______*_______________*
___*_______*_______*_______*
_*___*___*___*___*___*___*___*
*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*

Please provide code to print above binary tree pattern

sample data::

no. of lines =5
in first line leading spaces=15
in second line leading spaces=7 and middle spaces=15
in third line leading spaces=3 and middle spaces=7
and so on....

note here '_' depicts spaces.

1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

Give me code for this petrn

how can I display this pattern:

Enter Number: (ex.) 4
4444

(2nd) Enter Number: (ex.) 5
55555

plz any one help me to write code for
3
2 3 2
1 2 3 2 1
2 3 2
3

1000
0100
0010
0001
how this will be print in c?

how to print this format

2
3 5 7
11 15 19 23 27
29 35 41 47 53 59

/*
1 2 3 4 5
2 3 4 5 1
3 4 5 1 2
4 5 1 2 3
5 1 2 3 4
*/
how to print this pattern?

pls anyone send the code for this number pattern

47 51 61 71 81 91
48 52 62 72 82 92
49 53 63 73 83 93
50 54 64 74 84 94
55 65 75 85
56 66 76 86
57 67 77 87
58 68 78 88
59 69 79 89
60 70 80 90

47 51 61 71 81 91
48 52 62 72 82 92
49 53 63 73 83 93
50 54 64 74 84 94
55 65 75 85
56 66 76 86
57 67 77 87
58 68 78 88
59 69 79 89
60 70 80 90

write a program to get an output of
11111
10001
10001
11111
please help me

c code without using loops(only \n,\t) 4 rows only

*
* *
* * *
* * * *

c code without using loops(only \n,\t) 4 rows only


*
* *
* * *
* * * *

Write a simple C program to get the following output?
*************
*
*
*
*
*
*

code for output like
1
12
234
4567
7891011

code is
#include
#include
void main()
{
int i,j,k=1;
clrscr();
for(i=1;i<=5;i++)
{
for(j=i;j>=1;j--)
{
printf("%d",k);
k++;
}
printf("\n");
k--;
}
getch();
}

sry plz note this code for output like
1
12
234
4567
7891011

code is
#include
#include
void main()
{
int i,j,k=1;
clrscr();
for(i=1;i<=5;i++)
{
for(j=i;j>=1;j--)
{
printf("%d",k);
k++;
}
printf("\n");
k--;
}
getch();
}

This comment has been removed by the author.

code for output like this
1000
0100
0010
0001

#include
#include

int main(){

int arr[4];
for(int i=0; i<4;i++)
arr[i]=0;
for(int i=0; i<4; i++){
arr[i]=1;
if(i!=0)
arr[i-1]=0;
for(int j=0; j<4 ;j++){
printf("%d ", arr[j]);
}
printf("\n");
}


getch();
return 0;
}

lesser code for output like above

#include

void main(){

int arr[]={0,0,0,0};
for(int i=0; i<4; i++){
arr[i]=1;
if(i!=0)
arr[i-1]=0;
for(int j=0; j<4 ;j++)
printf("%d ", arr[j]);
printf("\n");
}
getchar();

}

Can anyone right a code for this?

1
12
123
1234
12345

~~~~~~~

12345
1234
123
12
1

~~~~~~

12345
1234
123
12
1

~~~~~

1
12
123
1234
12345

~~~~~~~THANK YOU!

i need code for the pattern
1
1 4 1
1 4 9 8 1
1 4 9 16 27 8 1
1 4 9 16 25 64 27 8 1

can anyone write a code for A
*
* * *
* *

************************ **** ***
************************ **** ***
*** **** ***
*** **** ***
************************ *********************
************************ *********************
*** **** ***
*** **** ***
************************ **** ***
************************ **** ***

Challenge ? Print this Pattern Using Only one For loop....u may use any number of other loops like while and if.......
you should not print whole line in printf like
printf("************************ **** ***");
follwed by condition like if >=2 print above line else other line.


Use your own logic

how to print this in c++?????????

1 1
12 21
123 321
1234 4321
123454321
1234 4321
123 321
12 21
1 1

***** *******
**********
***** *******
**********************

Anyone can help me generating the following type of pattern
if num=3(represents number of line )
then
1*2*3*10*11*12 //num=1
--4*5*8*9 //num=2
----6*7 //num=3
and accordingly if num is increased

This comment has been removed by the author.

can i have code for this pattern?
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25

i want to this type output.
*
* *
* *
* * * *

55555
4444
333
22
1
how to print ds..?

how to write followinh prgm in c by using while loop
1
2 3
4 5 6
7 8 9 10

how to write c prgm by using while loop output as follows
1
* *
1 2 3
* * * *
1 2 3 4

How to make this
*
***
*****
***
*
plz help me

what does printf(" ");means

how to print tis
if n=3
* *
* * * *
* * *

code for printing
*
**
***
****
*****

i need a program to print
10
101
1010
10101

salute to the person who has written such difficult programs ,,,anyone tell me can i get video tutorials of such programs anywhere...my yahoo id malik_02394@yahoo.com
my facebook id muhammad asim malik or engmuhammadasimmalik@yahoo.com

need a program for this pattern
*
* *
*
* *
*
* *

need a program for this pattern
*
* *
*
* *
*
* *

can anyone help me with this

13579
1357
135
13
1

thanks

this as well, please

1
2 4
1 3 5
2 4 6 8
1 3 5 7 9
2 4 6 8 10 12

thanks

code for this
=======
* *
* *
* *
* *
=======

This comment has been removed by the author.

code for this pattern------------
4 5 6
2 3
1

This comment has been removed by the author.
This comment has been removed by the author.

hi i need output for following
* * * * * * * * *
* * * *
* * * *
* *
* * * *
* * * *
* * * * * * * * *

Filename: calendar.c
Write a program that asks which day does the first day of the month falls and you will create a calendar for it.
Sample Run
In which day does the first day of Month X falls?
[1] Sunday
[2] Monday
[3] Tuesday
[4] Wednesday
[5] Thursday
[6] Friday
[7] Satuday 1
Output:
MONTH X 200X
S M T W Th F S
1 2 3 4 5 6 7
8 9 10 11 12 13 4
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

please provide me code for following * ** using single loop***
1
2 4
3 6 9
4 8 12 16
5 10 15 20

i need program for
1
22
333
4444
55555

This comment has been removed by the author.

I need prog..
1
2 3
4 5
6 7
5 4
3 2
1

/* Programmer: Chan
Programmed in g++ compiler

for further assistance regarding
any pattern, e-mail: chandan.16ck@gmail.com */

/* Method 1:
program to print:(on Anonymous demand)
* *
* *
* * */


#include
using namespace std;

main(){

int i,j,n;
cout<<"Enter number of lines=";
cin>>n;

for(i=0;i<n;i++){

for(j=0;j<2;j++){

cout<<"* ";

}

cout<<"\n";

}


}

/* Programmer: Chan
Programmed in g++ compiler

for further assistance regarding
any pattern, e-mail: chandan.16ck@gmail.com */

/* Method 2:
program to print:(on Anonymous demand)
* *
* *
* * */


#include
using namespace std;

main(){

int i,j,n;
cout<<"Enter number of lines=";
cin>>n;

for(i=0;i<n;i++){


cout<<"* *";



cout<<"\n";

}


}

/* Programmer: Chan
Programmed in g++ compiler

for further assistance regarding
any pattern, e-mail: chandan.16ck@gmail.com */

/* Method 2:
program to print:(on Anonymous demand)
* *
* *
* * */


#include
using namespace std;

main(){

int i,j,n;
cout<<"Enter number of lines=";
cin>>n;

for(i=0;i<n;i++){


cout<<"* *";



cout<<"\n";

}


}

please give me the code of this pattern in java

* * * *
*
* * * *
*
* * * *

print this format in java
* * * *
*
* * * *
*
* * * *

/* Programmer: Chan
Programmed in g++ compiler

for further assistance e-mail: chandan.16ck@gmail.com

code for this pattern:(On Amreesh Verma demand)
4 5 6
2 3
1 */


#include
using namespace std;

main(){

int i,j;
int n=4;

for(i=0;i<3;i++){

int k=n;

for(j=3;j>i;j--){

cout<<k++<<" ";

}

n=n/2;
cout<<"\n";

}

}

print this format in c programming
1
2 3
4 5 6
7 8 9 10

This comment has been removed by the author.

how to print this output
1 1
2 2 2
3 3 3
4 4 4
5 5

how to print
0
01
012
0123
01234
012345
01234
0123
012
01
0

/* Programmer: Chan
Programmed in g++ compiler

for further assistance e-mail: chandan.16ck@gmail.com

I need prog..(on ramesh jagtap demand)
1
2 3
4 5
6 7
5 4
3 2
1 */

#include
using namespace std;

main(){

int i,j;
int k=2;
int a=5;
for(i=1;i<=7;i++){

if(i==1||i==7)
cout<<"1";

else {

if(k==8){

for(j=1;j<=2;j++)
cout<<a--<<" ";

}

else {

for(j=1;j<=2;j++){

cout<<k++<<" ";

}

}

}

cout<<"\n";
}


}

please add header file iostream in all my posts as it is removed by the admin while publishing the posts......chan :-)

/* Programmer: Chan
Programmed in g++ compiler

for further assistance e-mail: chandan.16ck@gmail.com


How to print:(on Chanchal Singh Alchouni's demand)

1 1
2 2 2
3 3 3
4 4 4
5 5 */

#include
using namespace std;

main(){

int i,j;

for(i=1;i<=5;i++){

if(i==1 || i==5){

for(j=1;j<=2;j++)
cout<<i<<" ";

}

else {

for(j=1;j<=3;j++)
cout<<i<<" ";

}

cout<<endl;

}

}

please print this
sssssssss
sssssssss
ssssossss
sssssssss
sssssssss

pls print as:
sssss
s s
s s
s s
sssss

54321
5432
543
54
5

Please give me this pattern and the corresponding program..pleaseeee

This comment has been removed by the author.

program for pattern
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1

This comment has been removed by the author.
This comment has been removed by the author.

......*
...* A *
.* A B C *
...* A *
......*

how to print this in c?
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4

program for pattern
4444
333
22
1

I need a code for this type print
***************************
*********
***

*
* *
* * *
* * * *
* * *
* *
*
write a program to print this pattern??????????

write a program to print the pattern 2,4,6,12,20,30.........

This comment has been removed by the author.

pattern to print a "N" using "*" in C programming ,,, please help...

i need program :-
qwer
wer
er
r

i need program :-
12345
23451
34512
45123
51234

i want the coding of
5
54
543
5432
54321

i want code for this pattern
1
32
654
10987

PROGRAM TO PRINT THE FOLLOWING OUTPUT:
1
1 2
2 3 4
4 5 6 7
7 8 9
9 10
10

int num=Integer.parseInt(tf1.getText());
int n,r=1,c;
int i,j,k=1;
for(i=1;i=1;n--)
{
for(c=1;c<=n;c++)
{
System.out.print(" "+k);k++;
}k--;
System.out.print("\n");
} }

to generate lund in c- language

how can this pattern be generated please help its urgent:-
mail me at uppy54@gmail.com
1 2 3 4 5
16 6
15 7
14 8
13 12 11 10 9

wrote a program to print the following
here R=space.
please mail me at uppy54@gmail.com

1RR2RR3R 4R5
16RRRRRRRR6
15RRRRRRRR7
14RRRRRRRR8
13R12R11R10 9

need an output like in c
Can any one help me????/
1
3 2
6 5 4
10 9 8 7

#include
int main()
{
int i,j,max_val,print_val;
//max_val first or maximum value for that line
//print_val current value that should be printed
max_val=0;
for(i=1;i<=4;i++)
{
max_val+=i;//max_val=max_val+i;
print_val=max_val;
for(j=1;j<=i;j++)
{
printf("%d ",print_val);
print_val--;
}
printf("\n");
}
return 0;
}

#include
int main()
{
int i,j,max_val,print_val;
//max_val first or maximum value for that line
//print_val current value that should be printed
max_val=0;
for(i=1;i<=4;i++)
{
max_val+=i;//max_val=max_val+i;
print_val=max_val;
for(j=1;j<=i;j++)
{
printf("%d ",print_val);
print_val--;
}
printf("\n");
}
return 0;
}

output
1
3 2
6 5 4
10 9 8 7

aofcprogramming.blogspot.com

what is the program when you have a pattern like this:
654321
65432
6543
654
65
6

thanks

This comment has been removed by the author.

I want this code. Please help me..

1
3*2
4*5*6
10*9*8*7
11*12*13*14*15

This comment has been removed by the author.
This comment has been removed by the author.

how is this

123
234
345 ... for given value of n

I want following ouput please help me...
1
2 7
3 8 12
4 9 13 16
5 10 14 17 19
6 11 15 18 20 21

first line is value of loop i i.e
1
2
3
4
5
6


1
2 7(2+5)
3 8(3+5) 12(8+4)
4 9(4+5) 13(9+4) 16(13+3)
and so on

#include
int main()
{
int i,j,fix,curval=0;

for(i=1;i<=6;i++)
{
fix=5;
curval=i+fix;
for(j=1;j<=i;j++)
{
if(j==1)
printf("%2d ",i);

if(j>1)
{
printf("%2d ",curval);
fix--;
curval=curval+fix;
}
}
printf("\n");
}
return 0;
}

add stdio.h after include in above

More Pattern Here

Basic
http://geeksprogrammings.blogspot.com/2013/09/print-star-triangle.html

Tricky Pyramids and patterns
http://geeksprogrammings.blogspot.com/2013/06/program-to-print-pyramids-on-screen.html

More Pattern and interview questions
http://aofcprogramming.blogspot.com
post your questions too

i need aprogram like if array consist of[2,-2,3]
the thiw will be the pattern
**// tgis is for +2
** //this is for -2
***

output
enter num 5
12345
enter num 7
1234567

1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1

help for this .. code

*********
********
*******
******
*****
****
***
**
*
********
******
****
**
*
**
***
****
*****
******

write a this type of prog in ca lang

print this
A
A B C
A B C D E
A B C D E F G

This comment has been removed by the author.

#include
#include
void main(void)
{
char i,j;
clrscr();
for(i='A';i<='F';i++)
{
for(j='A';j<=i;j++)
printf("%c",j);
printf("\n");
}
getch();
}

This comment has been removed by the author.
This comment has been removed by the author.
This comment has been removed by the author.

i want the following program
1 1 1 1
0 0 0 0
1 1 1 1
0 0 0 0
PLZ HELP ME SOOON

for odd line number 1 is printed
for even line number 0 is printed
so feed line number counter to modulus 2 (remainder division )
in case of 1, 3 line number modulus 2 will print 1
in case of 2,4 line number modulus 2 will print 0

#include
int main()
{
int i,j;

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

How to get the following output.

0*********
*1********
**2*******
***3******
****4*****
*****5****
******6***
*******7**
********8*
*********9

1
01
101
0101
10101
ans:
#include
#include
void main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
if((i+j)%2==0)
printf("%d",1);
else
printf("%d",0);
}
printf("\n");
}
getch();
}

how to print???
11
121
1331
14641

pls help....

how to print???
11
121
1331
14641

pls help....

how to print???
11
121
1331
14641

pls help....

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

I Need code to print the pattern:
4444
333
22
1
please reply

«Oldest ‹Older   1 – 200 of 242   Newer› Newest»

Post a Comment