how can i get output the following...
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1

and

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

plz plz...

Answers were Sorted based on User's Feedback



how can i get output the following... 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 and ..

Answer / aditi

For first one:-
void main ()
{
for (int i= 5; i>= 1; i--)
{
for (int k=5; k >= 1; k--)
{
if (k> i)
printf(" ");
else
printf ("%d", k);
}
printf("\n");
}
}


For second:-
void main ()
{
int n = 0;

for (int i=1; i<6; i++)
{


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

Is This Answer Correct ?    12 Yes 1 No

how can i get output the following... 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 and ..

Answer / abhishek karnani

void main ()
{
int i,k,j;
clrscr();
for (i=0;i<5;i++)
{

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


}

}

Is This Answer Correct ?    2 Yes 1 No

how can i get output the following... 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 and ..

Answer / anas

for(i=n;i>=1;i--)
{
for(c=1;c<=n-i;c++)
{
cout<<" ";
}
for(k=i;k>=1;k--)
{
cout<<k;
}
cout<<"\n";
}
----------------------------------------------
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
//for second.
int n=1;
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
cout<<n<<" ";
n++;
}
cout<<"\n";
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

How do you do dynamic memory allocation in C applications?

0 Answers  


1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision

9 Answers   HCL, Qualcomm,


How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;

2 Answers  


what is used instead of pointers in java than c?

1 Answers   Vuram,


which of the function operator cannot be over loaded a) <= b)?: c)== d)*

10 Answers   Cisco, CTS, Google, HCL, HP,






Explain the difference between malloc() and calloc() function?

0 Answers  


#include<stdio.h> #include<conio.h> struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

2 Answers   Facebook,


what is difference between overriding and overloading?

1 Answers  


Difference between linking and loading?

0 Answers  


wat s the meaning of (int *)p +4;

2 Answers  


What is struct node in c?

0 Answers  


define switch statement?

6 Answers   CTS,


Categories