prog. to produce 1
2 3
4 5 6
7 8 9 10

Answers were Sorted based on User's Feedback



prog. to produce 1 2 3 4 5 6 ..

Answer / devendra lohiya

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l,sp=7;
clrscr();
for(i=1,k=1;i<5;i++)
{
for(l=1;l<sp;l++)
printf(" ");
sp-=2;
printf(" ");
for(j=1;j<=i;j++,k++)
{
printf(" ");
printf("%d",k);
printf(" ");
}
printf("\n");
}
getch();
}

Is This Answer Correct ?    2 Yes 0 No

prog. to produce 1 2 3 4 5 6 ..

Answer / sudhanshu kumar

#include<stdio.h>
#include<conio.h>

void main()
{
int nol,i,j,k=1,l=1;
clrscr();
printf("Enter the no. of line: ");
scanf("%d",&nol);
for(i=nol*2;i>=2; i=i-2)
{
printf("\n\n");
for(j=1;j<=i;j++)
printf(" ");

for(j=1;j<=l;j++)
printf("%2d ",k++);
l++;
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No

prog. to produce 1 2 3 4 5 6 ..

Answer / gaurav singh

In c++ u can write like this

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j=0,k=1,s=0;
cout<<"pattern \n";
for(i=1;i<=4;i++)
{
for(s=4-i;s>0;s--)
{
cout<<" ";
}
for(j=i;j>0;j--)
{
cout<<k;
k++;
cout<<" ";
}
cout<<"\n";
}

getch();
}

Is This Answer Correct ?    0 Yes 0 No

prog. to produce 1 2 3 4 5 6 ..

Answer / mini

#include<stdio.h>
#include<conio.h>
main()
{
int i,n;
printf("enter the number to n")
scanf(%d,\n)
i=1,i++;
i<=10;
printf("he result is \i")
getch();
}

Is This Answer Correct ?    0 Yes 7 No

Post New Answer

More C Code Interview Questions

main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

1 Answers   DCE,


main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O

4 Answers   HCL,


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

9 Answers   Microsoft,


write a program for area of circumference of shapes

0 Answers  


main() { int i=-1; -i; printf("i = %d, -i = %d \n",i,-i); }

1 Answers  






void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

2 Answers  


Is the following code legal? typedef struct a { int x; aType *b; }aType

1 Answers  


main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }

1 Answers  


what will be the position of the file marker? a: fseek(ptr,0,SEEK_SET); b: fseek(ptr,0,SEEK_CUR);

2 Answers  


What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is assigned to pointer p printf("%f", i/(*p) ); // i is divided by pointer p } a. Runtime error. b. 1.00000 c. Compile error d. 0.00000

3 Answers   HCL,


main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024

2 Answers   HCL,


Categories