write a program to display the numbers in the following
format
4 4
3 3 3 3
2 2 2 2 2 2
1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1
2 2 2 2 2
3 3 3
4

Answers were Sorted based on User's Feedback



write a program to display the numbers in the following format 4 4 3 3 ..

Answer / vidyullatha

#include<stdio.h>

main()
{
int i=0,k=0,l=0;
int cnt=1;
int space=7;
for (i=4;i>0;i--)
{
for(l=1;l<=cnt;l++)
{
printf("%d ",i);
}
for(k=0;k<space;k++)
{
printf(" ");
}
for(l=1;l<=cnt;l++)
{
printf("%d ",i);
}
cnt++;
space=space-2;
printf("\n");
}
for(i=0;i<9;i++)
{
printf("0 ");
}
printf("\n");
cnt=7;
for(i=1;i<=4;i++)
{
for(k=0;k<i;k++)
printf(" ");
for(l=1;l<=cnt;l++)
{
printf("%d ",i);
}
printf("\n");
cnt=cnt-2;
}
}

Is This Answer Correct ?    19 Yes 1 No

write a program to display the numbers in the following format 4 4 3 3 ..

Answer / jankipatel

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l,p;
clrscr();
// printf("enter the value\n");
// scanf("%d",&l);
for(i=4;i>=0;i--)
{
for(j=4;j>=i;j--)
{
// textcolor(0-i);
printf("%d ",i);
}
for(k=0;k<=i-1;k++)
{
printf(" ");
}
for(k=0;k<=i-1;k++)
{
printf(" ");
}
for(j=4;j>=i;j--)
{
// textcolor(0-i);
printf(" %d",i);
}
printf("\n");
}


for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
printf(" ");
}

for(k=4;k>=i;k--)
{
printf("%d ",i);
}
for(k=4;k>=i;k--)
{
printf(" %d",i);
}
printf("\n");
}



getch();
}

Is This Answer Correct ?    2 Yes 0 No

write a program to display the numbers in the following format 4 4 3 3 ..

Answer / meet parikh

public class Arrow_1 {
private final int LARG = 4;
String printint,fillint;
boolean display = false;
public Arrow_1(){
fillint = " ";
for(int i = LARG; i >= 0; i--){
if(i == 0){
display = true;
fillint = 0 + "";
}
StringBuilder sb = new StringBuilder();
printint = i + "";
insertDisp(sb, i);
System.out.println(sb.toString());
}
printint = " ";
for(int i = LARG; i>0;i--){
StringBuilder sb = new StringBuilder();
fillint = LARG - (i-1) + "";
insertDisp(sb,i);
System.out.println(sb.toString());
}
}
private void insertDisp(StringBuilder sb,int number){
printDisp(sb, number);
fillempty(sb, number);
if(display){
sb.append(fillint);
} else {
sb.append(" ");
}
fillempty(sb, number);
printDisp(sb, number);
}
private void printDisp(StringBuilder sb,int number){
int itr;
if(number == 0){
itr = LARG;
} else {
itr = LARG - (number-1);
}
for(int i = 0 ; i < itr;i++){
sb.append(printint);
}
}
private void fillempty(StringBuilder sb, int number){
for(int i = 0; i < number-1 ;i++ ){
sb.append(fillint);
}
}
public static void main(String args[]){
new Arrow_1();
}
}

Is This Answer Correct ?    1 Yes 0 No

write a program to display the numbers in the following format 4 4 3 3 ..

Answer / padmapriya

class Pattern{
public static void main(String[]args){
for(int i=4;i>0;i--){
for(int j=0;j<5-i;j++){
System.out.print(i);

}
for(int j=0;j<i;j++){
System.out.print(" ");
}
for(int j=0;j<i-1;j++){
System.out.print(" ");
}
for(int j=0;j<5-i;j++){
System.out.print(i);
}
System.out.println();
}

for(int i=0;i<5;i++){
for(int j=0;j<i;j++){
System.out.print(" ");
}
for(int j=0;j<9-2*i;j++){
System.out.print(i);
}
System.out.println();
}
}
}

Is This Answer Correct ?    1 Yes 0 No

write a program to display the numbers in the following format 4 4 3 3 ..

Answer / mahesh

#include<stdio.h>
int main()
{
int a=2,n=4,i,j,k;
for (i=4;i>=0;i--)
{
for(j=0;j<a;j++)
{
printf("%d",n);
}
printf("
");
a=a+2;
n--;

}
n=1;
a=a-4;
for(i=0;i<=4;i++)
{
for(j=0;j<a;j++)
{
printf("%d",n);
}
printf("
");
a=a-2;
n++;
}
}

Is This Answer Correct ?    2 Yes 1 No

write a program to display the numbers in the following format 4 4 3 3 ..

Answer / meet parikh

the above answer is in Java...........

Is This Answer Correct ?    0 Yes 0 No

write a program to display the numbers in the following format 4 4 3 3 ..

Answer / bharath_471

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l,n;
clrscr();
printf("enter the number");
scanf("%d",&n);
for(j=n,l=1;(j>0 && l<=n);j--,l++)
{
for(k=1;k<=2*l;k++)
printf("%d",j);
printf("
");
}
for(j=0,l=n;(j<=n && l>=0) ;j++,l--)
{
for(k=1;k<=2*l+1;k++)
printf("%d",j);
printf("
");
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No

write a program to display the numbers in the following format 4 4 3 3 ..

Answer / vamsi talapatra

#include<iostream>
using namespace std;
int main(){
int n = 4;
int e = 2;
while(n>0){
for(int i = 0; i< e ; i++){
cout<<n<<" ";
}
cout<<endl;
e=e+2;
n--;
}

while(n<=4){
for(int i = 1; i< e ; i++){
cout<<n<<" ";
}
cout<<endl;
e=e-2;
n++;
}
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

write a program to display the numbers in the following format 4 4 3 3 ..

Answer / venkatesh

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {

int i,j,k,n1,n2;
printf("
enter n1 value:");
scanf("%d",&n1);
k=4;
for(i=1;i<=n1;)
{

for(j=i;j<=2*i;j++)
{
printf("%d ",k);

}

printf("
");
i=i+2;
k=k-1;
}
k=0;
n2=n1+1;
for(i=9;i>=1;)
{
for(j=1;j<=i;j++)
{
printf("%d ",k);
}
printf("
");
k=k+1;
i=i-2;
}

return 0;
}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

What is local and global variable in c?

0 Answers  


How many types of errors are there in c language? Explain

0 Answers  


User define function contain thier own address or not.

2 Answers  


The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.

0 Answers  


#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) malloc(25); strcpy(p1,"Ramco"); strcpy(p2,"Systems"); strcat(p1,p2); printf("%s",p1); } Tell me the output?

6 Answers   Ramco,






what is the difference between #include<stdio.h> and #include "stdio.h" ?

3 Answers  


How can you invoke another program from within a C program?

0 Answers  


how to write a data 10 in address location 0x2000

3 Answers  


In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.

0 Answers  


What does the format %10.2 mean when included in a printf statement?

0 Answers  


Write a C++ program to give the number of days in each month according to what the user entered. example: the user enters June the program must count number of days from January up to June

0 Answers  


What is the advantage of using #define to declare a constant?

0 Answers   Agilent, ZS Associates,


Categories