Sharad Sharma's Avatar, Join Date: Aug 2011
Newbie Member
1
121
12321

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long n,j,p=0,q;
clrscr();
printf("\n Enter the number of rows : ");
scanf("%ld",&n);
for(j=0;j<=n-1;j++)
{
p=1*pow(10,j)+p;
q=p*p;
printf("%ld",q);
printf("\n");
}
getch();
}
Sharad Sharma's Avatar, Join Date: Aug 2011
Newbie Member
(2)
1
121
12321

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long n,j,p=0,q;
clrscr();
printf("\n Enter the number of rows : ");
scanf("%ld",&n);
for(j=0;j<=n-1;j++)
{
p=1*pow(10,j)+p;
q=p*p;
printf("%ld",q);
printf("\n");
}
getch();
}
abhix95 like this
abhix95's Avatar, Join Date: Jan 2012
Newbie Member
1
11
112
11235
112358

#include<iostream.h>
#include<conio.h>
void main()
{
int a, b,c,r,p=0,n=1;
clrscr();
cout<<"Enter number of line";
cin>>a;
for(b=1;b<=a;b++)
{
cout<<1<<"\t";
for(c=1;c<b;c++)
{
r=p+n;
p=n;
n=r;
cout<<r<<"\t";
}
cout<<endl;
n=1;
p=r=0;
}
getch();
}
cwizard's Avatar, Join Date: Jul 2012
Newbie Member
Code:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[20],n;
a[0]=1;
a[1]=1;
cout<<"Enter the limit"<<endl;
cin>>n;
for(int j=1;j<=n;j++)
 {
  for(int i=2;i<=j;i++)
  {
   a[i]=a[i-1]+a[(i-1)-1];
  }
 }
for(j=0;j<=n;j++)
 {
  for(int i=0;i<=j;i++)
  {
  cout<<a[i];
  }
 cout<<endl;
 }
getch();
}

Last edited by shabbir; 30Jul2012 at 10:32.. Reason: Code blocks
vijayuit's Avatar, Join Date: Aug 2012
Newbie Member
Code:
#include<stdio.h>
void main(){
int n,i,j,f1=0,f2=1,f3=0,k,a[25];
printf("ENTER THE NUMBER\n");
scanf("%d",&n);
for(i=1;i<n;i++)
{
f1=f2;
f2=f3;
f3=f2+f1;
a[i]=f3;
for(j=1;j<=i;j++)
{
printf("%d\t",a[j]);
}
printf("\n");
}
}

Last edited by shabbir; 3Aug2012 at 18:51.. Reason: Code blocks
vijayuit's Avatar, Join Date: Aug 2012
Newbie Member
Code:
#include<stdio.h>
void main(){
int n,i,j,k;
printf("ENTER THE NUMBER\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf("%d",j);
for(k=j-2;k>0;k--)
printf("%d",k);
printf("\n");
}
}

Last edited by shabbir; 3Aug2012 at 18:52.. Reason: Code blocks
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
But where are the *difficult* C programs? These 10-15 line tiddlers might be challenging for beginners for about 5 minutes, but that doesn't qualify them to be called difficult. IOCCC - now THERE are some difficult C programs!
manojgdhv's Avatar, Join Date: Aug 2012
Newbie Member
1)
Code:
void main()
{
int f1=1,f2=1,f3=0,n=5,i,j;
for(i=1;i<=5;i++)
{
   printf("\n%d %d ",f1,f2);
   for(j=2;j<=i;j++)
   {
    
    f3=f1+f2;
    printf("%d ",f3);
    f1=f2;
    f2=f3;
   }
}
}
 2)
void main()
{
int i=0,j=0;
for(i=1;i<=4;i++)
{
    for(j=1;j<=i;j++)
  printf("%d",j);
  for(j=i-1;j>=1;j--)
  printf("%d",j);
printf("\n");
}
}

Last edited by shabbir; 17Aug2012 at 19:25.. Reason: Code blocks
Kush Pandey's Avatar, Join Date: Jan 2013
Newbie Member
here is the output of program to print
11
112
1123
11235
112358


Code:
#include<stdio.h>
#include<conio.h>
 main(){
    int i,j,a=1,b=1,c;

    for(i=1;i<=5;i++)
    {
        printf("%d\t%d\t",a,b);
    for(j=3;j<=i+1;j++)
    {
        c=a+b;
        printf("%d\t",c);
        a=b;
        b=c;
    }
    a=1;b=1;
    printf("\n");
    }
}

Last edited by shabbir; 10Jan2013 at 12:01.. Reason: Code blocks
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Just thought I'd borrow something from IOCCC to show you people what a difficult C program really looks like. These piddly examples to draw stars in triangles or whatever are nothing compared to these:
Code:
#include<stdio.h> /******** SpigotQuine -- usage: ./spigot [pi or e] ********/
char*s="G1%%xJ{;Q7wunmuGuu%%uu#include<stdio.h>/*Spigot_Quine*/#include<stdli"
"b.h>/*_IOCCC2012_*/int*e,"    "i,j,k,n"     ";char*q"    ",*a,*d,*z,*p=%s%c;"
"int" "%cmain(){a=calloc("                                 "1,1e4+n*2);;for(*"
"a=\0@3,z=d=a+n+1,j=n*8-7;"    "k=0,j-1"     ";j-=2){"    "for(a[1]+=2;--z-a;"
"*z=k%%10,k/=10)k+=j/2**z;;for(;k=k%%j*"     "10+*++z,z<d;)*z=k/" "j;;\0@2,z="
"d=a+n*2,*z=1,j=0;++j<n;){for(;k=k%%"           "j*10+*z,a-z;*z"   "--=k/j)a+"
"+;for(k=0;z-d;*a--=k%%10,k/=10)k+"               "=*++z+*a\0"     "@;}d+=spr"
"intf(q=d-20,p,p,34,32,n+1)+2;;;;"                 "for(n=n*2"     "0-400;k<n"
";++k%%n?j=!puts("                                                 "d):(d[j]="
"47,d++,d[j-2"                                                     "]=42),k%%"
"20<1?puts(d"                                                      "-1),a++:0"
"){for(i=-1"                                                       ";i++<32;!"
"*z?q[662]"          "=0,z=q+207:"                 "*z+z[1]<6"     "5?z+=11:*"
"z==34?p=0"         ":0)d[i]=((k/2"               "0-1?275*q["     "*a+10]-8*"
"q[*a+0]-8"         ":128)>>(i/11+k/"           "4%%5*3))&1?k"     "/3*!j&&p?"
"j=34:(j="           "i+1,*z++):32;k/3*"     "j--&&p?d[z--,j]=3"   "4:0;}}int"
"*y,n=%d;/*..~",*f="nnLa5~z23~|22t$q(s82r&q(s82q'q(s8;q(s8;q(s8:" "r(s8:r(s8:"
"q)s89r)sLr#t+" "sLx,uJw-yGu/wnnnU",*g="nnLa<z::t$u88t(u67t*u57s,t56t,t56~v56"
"tF6tF6tF8t1p"   "Nu/qOv+rS}Xxnng";int main(int m,char**v){char a[2012],b[2012
],*p=a,*r=m>1     &&*v[1]=='e'?g:f,*q=b,*t=r;;sprintf(a,"%s%s%s",s,r==g?s+281:
s+168,s+386);     sprintf(b,a+22,a,34,32,24);for(sprintf(a,"%.33s/*%.28s*/%.3"
"3s/*%.28s*/%"   ".33s\"%s*/",b,b+66,b+33,b+76,b+66,b+99);*r;r++){;for(m=0;m++
<(*r-34)%77;*q++=*r>111?32:*p++)(q-b)%66<1?*q++=10:0;*r-110&&*r-126&&r-t<(t-g?
62:45)?*q++=34,((q-b)%66<1?*q++=10,*q++=34:0):0;}*q=0;puts(b+1);}/*IOCCC2012*/