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

How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)

0 Answers  


how to convert decimal to binary in c using while loop without using array

50 Answers   Apple, Aptech, Arwen Tech, BCS, C2D Software, CEC,


What are the different types of errors in C and when they occur?

4 Answers  


what is macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?

2 Answers   TCS,


Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.

2 Answers   HCL,






Write a program to accept two strings of Odd lengths. Then take all odd characters from one string and even characters from the other and concatenate and produce a string.

1 Answers  


I'm having trouble with coming up with the correct code. Thank You!! The assignment was to write a program using string functions that accepts a price of an item and displays its coded value. The base of the keys: X C O M P U T E R S 0 1 2 3 4 5 6 7 8 9 Sample I/O Dialogue: Enter Price: 489.50 Coded Value: PRS.UX

0 Answers  


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

3 Answers  


what is meant for variable not found?

3 Answers  


void main() { int i=7; printf("N= %*d",i,i); }

6 Answers   HCL,


I can not get my C++ program to work right. It is supposed to tell if a word is a palindrome or not, but it only tells thet the word is not a palindrome. And I can't fix it.

1 Answers  


void main() { int i=5; printf("%d",i+++++i); }

14 Answers   HCL,


Categories