What is the code for following o/p
*
* *
* *
* *
* *
* *
* *
* *
*



What is the code for following o/p * * * * * * * * * * * ..

Answer / unknown

#include<stdio.h>

void main()
{
int i,j,k,num = 5;

for(i = num;i > 0;i--){
for(j = 1;j <= i;j++){
printf(" ");
}
for(k = (j - 1);k < num;k++){
if(k==j-1 || k==num-1)
printf("*");
else
printf(" ");
printf(" ");
}
printf(" \n");
}


for(i = num;i > 0;i--){
for(j = (num - i);j > 0;j--){
printf(" ");
}
for(k = 0;k < i;k++){
if(k==0|| k==i-1)
printf("*");
else
printf(" ");
printf(" ");
}
printf(" \n");
}
}

Is This Answer Correct ?    6 Yes 1 No

Post New Answer

More C C++ Errors Interview Questions

Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;

3 Answers  


A sample program using data structure? what is file handling?

0 Answers   TCS,


void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..

32 Answers   College School Exams Tests, CTS, HCL, iGate, SmartData,


How to reverse a linked list without using array & -1? Thank you.

2 Answers   Access, Satyam,


Why are memory errors hard to debug?

1 Answers  






Write down the difference between c. Loop and goto statement d. (!0) and (!1) e. (1= =! 1) and (1!=1) f. NULL and !NULL

0 Answers  


Answering Yes or No in C++...using only stdio.h and conio.h..........help me please...? here's must be the output of the program: Screen A Exam No. items Score 1 20 20 2 35 35 Another Entry? [Y] or [N] : Screen B: Record No. Student's Name: 1 Fernando Torres 2 Chuck Norris Note: if you press Y, the program must repeat the procedure in screen A, then if N, the program must proceed to the screen B....Please Help me out............

1 Answers  


To generate the series 1+3+5+7+... using C program

18 Answers  


write a profram for selection sort whats the error in it?

2 Answers  


what is syntax error?

3 Answers  


Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0. Instructor's notes: This problem requires either a while or a do-while loop.

3 Answers  


which typw of errors ? & how to solve it ?

0 Answers  


Categories