1 121 12421 1248421 print these in C programming?

already exists.

Would you like to merge this question into it?

already exists as an alternate of this question.

Would you like to make it the primary and merge this question into it?

exists and is an alternate of .

the series continues with the length of odd series ie.1,3,5,7...so on.the middle integer is extra sdded in every number.it's general structure is
(inital numbers)(extra number)(reverse of initial numbers)

extra number is always multplied by 2 with last extra number added

char s[50];
s[0]=1;
for(i=1;i<n;i++)
{
traverse the array to next middle position
add the extra element in between the elements
concatenate the reverse part of initial elements
}

this can b done as

for(i=1,j=0;i<n;i=strlen(s),j++)
{
for(k=i;k>j;k--)
{
s[k+1]=s[k];
}

s[j+1]=s[j-1]*2;
s[i+3]='\0';
print s;
}
8 people found this useful

C program to print prime numbers?

class primenoSeries { void main () { int i = 1; // Used to divide number and check if they are factors or not. int C = 0; // used as a counter for number of factors. int n = 1; // Represent the numbers. while (n > 0) { if ( n % i 0 ) { C++; if ( C 2 && i n) { System.ou (MORE)

Write a program in C to print 1 -4 7-10 13 -16?

hi here is the program for u. //program to print the series 1,-4,7,-10,13,-16 etc... #include #include void main() { int i,n,sign=1; printf("Enter the number of terms to which u want to print the series\n"); scanf("%d",&n); for(i=1;i

C program to print how many prime numbers are there from 1 to 50?

Here is a simple program to generate prime numbers upto a given specific number /*Prime No. from 1 to 50*/ /*By-Himanshu Rathee*/ #include #include void main() { int i,j,n; clrscr(); printf(" Enter the number upto which we have to find the prime number: "); scanf("%d",&n); printf (MORE)

Write a C program to print Denominations?

in this example I deal with fictive currency namely: Gold, Silver and Copper coins.. 1 Gold is 100 Silver. 1 Silver is 100 Copper (thus 1 gold is 10000 copper). include . include . void denominate(int Copper). {. DWORD myCopper = Copper % 100;. DWORD mySilver = Copper/100 % 100;. DWORD myG (MORE)

Write a program to print Armstrong in c?

void main() { int n,b=0,t; clrscr(); printf("Enter the no"); scanf("%d",&n); t=n; while(n>0) { a=n%10; b=b+a*a*a; n=n/10; } if(b==t) { printf("Armstrong no"); } else { printf("Not an Armstrong no"); } getch(); }

1 121 12321 1234321 program?

1^2 = 1 11^2 = 121 111^2 = 12321 1111^2 = 1234321 11111^2 = 123454321 #include #include #include void main() { clrscr(); int n;//soullessgod coutn; int a=1,b,s=1; for(;a=1;b--) { cout

Write a C program to print the pattern 1 1 2 1 2 3 1 2 3 4?

// Here are three ways to answer your question. Hope it's not a homework assignment!\n. \n// -----Method 1------ //\n . include \n int main() {\nprintf("1121231234");\nreturn 0;\n}\n. \n// -----Method 2------ //\n . include \n int main() {\nint i, j;\nfor(i=1; i

What is the c plus plus program to print armstrong numbers from 1 to 100?

include #include unsigned count_digits (unsigned num, const unsigned base=10) { unsigned count=1; while (num/=base) ++count; return count; } class number { std::vector value; unsigned base; public: number (const unsigned _value, const unsigned _base=10): value {}, base {_base} { *this = _value; (MORE)

A program in c for matrix printing?

//program to get numbers from user and print the matrix #include int main() { int i,n,j,a[10][10]; printf("\n enter the number of elements "); scanf("%d",&n); for(i=0;i

C program to print Adam number?

include . include . void main(). {. int i,n,n1,n2,ns,r,rev=0,nr=0,nrs;. clrscr();. printf("Enter a no.n");. scanf("%d",&n);. ns=n;. n1=n*n;. n2=n1;. while(n2>0). {. r=n2%10;. n2=n2/10;. rev=rev*10+r;. }. while(ns>0). {. r=ns%10;. ns=ns/10;. nr=nr*10+r;. }. nrs=nr*nr;. if (rev (MORE)

C program to print a matrix?

If this is a homework assignment, please consider trying it yourself first. Otherwise, you will lose the value of the reinforcement of the lesson that doing the homework provides. . int matrix[ROWS][COLUMNS]; . int row, column; . for (row=0; row

C program to print a number in words?

class abc { void main( int num ) { int d = 1; int dig = 0; int temp = num; System.out.println(temp); while(num > 9) { num = num / 10 ; d = d * 10; } while( d != 0) { dig = temp / d; if( dig 1) System.out.print("One"); if( dig 2) System.out.print("Two"); if( (MORE)

Write a C program to print numbers from 1 to 99 in words?

include #include void one(int m) { int n; n=m%10; switch(n) { case 1:printf("One"); case 2:printf("Two"); . . . case 9:........ } } void ten(m) { int a=m%10; switch(m) { case 11:printf("Eleven"); ........ case 15:.... } if(m>15 && m=20 && m=30 && m

C program to print the largest digit of a no?

include #include int main(int argc, char *argv[]){ int numval, highval = 0; if(argc != 2){ printf("syntax:\n\tfoo number\n"); exit(1); . } numval = atoi(argv[1]); while(numval > 0){ if(numval % 10 > highval){ highval = numval % 10; . } numval = (int)(numval / 10); . } (MORE)

How do you print the numbers 1 11 121 1331 14641in pyramid form in c?

include #include #include int count=0; char arr1[20],arr2[20]; int main() { int j; arr1[0]=1; arr1[1]='\0'; int flag=3; for(j=3;j>=-1;j--) printf(" "); printf("1\n"); while(flag>=0) { for(j=3;j>=count;j--) printf(" "); arr2[0]=arr1[0]; arr2[strlen(arr1)]=arr1[strlen(arr1)-1]; for(j=1;j

Write a c program to print factorial?

/*program for finding the factorial*/ void main() { int a,b=1; clrscr(); printf("Please enter any number to find its factorial\n"); scanf("%d",&a); while(a>1) { b=b*a; a--; } printf("factorial is %d",b); getch(); }

C program to print helical matrix?

//the following code will help you to write the program for(i=n-1, j=0; i > 0; i--, j++) //n is the order of the square matrix { for(k=j; k < i; k++) printf("%d ", a[j][k]); for(k=j; k < i; k++) printf("%d ", a[k][i]); for(k=i; k > j; k--) printf("%d ", a[i][k]); for(k=i; k > j; k--) printf (MORE)

How you write a program in c plus plus to print plaindromic numbers from 1 to n?

To check if a number is a palindrome, reverse the number and see ifit is equal to the original number. If so, the number is apalindrome, otherwise it is not. To reverse a number, use thefollowing function: int reverse(int num, int base=10) { int reverse=0; while( num ) { reverse*=base; reverse+=nu (MORE)

A program prints vertically a numbers in c program?

It is too easy................ //Program to print numbers vertically #include #include void main() { int last_no; int i; clrscr(); i=0; printf("Enter your last num.I will print 0 to that number"); scanf("%d",&last_no); printf("\n"); while(i>last_no) { printf("%d\n",i); i++; } getch(); } (MORE)

How do you write a c program to prints name?

Write a c program that reads your first name and surname when you enter them. Each part of your name should not be more than 12 characters. Finally, have the program display your full name.

Write a C program to print a name?

include int main(void) { printf("Hello world!"); return 0; } Of course, all you have to do is merely replace "Hello, world!" with your chosen name.

How do you write a C program to print how many prime numbers there are from 1 to 1000000?

First, you need a function that can determine if a given number isprime or not: #include bool is_prime (unsigned num) { if (num < 2) return false; if (!(num % 2)) return num == 2; // 2 is the only even prime unsigned max = (unsigned) sqrt ((double) num) + 1; for (unsigned div = 3; div < max; div + (MORE)

1 121 12421 1248421 print these in php programming?

Assuming you just want those integers printed you can do so likethis: However, if you're looking for how to print these in some sort ofpower of 2 in terms of a homework assignment, you can pretty easilyfind some hints by simple searching the significance of thosenumbers.