given integer number,write a program that displays the
number as follows:
First line :all digits
second line : all except the first digit
.
.
.
.
Last line : the last digit

Answers were Sorted based on User's Feedback



given integer number,write a program that displays the number as follows: First line :all digits ..

Answer / jickson

#include<stdio.h>
main()
{
int num,dcount,temp,i,j;
int array[20];
printf("\nEnter a number:");
scanf("%d",&num);
temp=num;
for(dcount=0;num!=0;num=num/10,dcount++);
for(i=dcount;i>0;i--)
{
array[i-1]=temp%10;
temp=temp/10;
}
printf("Required Pattern is:\n");
for(i=0;i<dcount;i++)
{
for(j=i;j<dcount;j++)
printf("%d\t",array[j]);
printf("\n");
}

}

Is This Answer Correct ?    41 Yes 13 No

given integer number,write a program that displays the number as follows: First line :all digits ..

Answer / shams

#include <stdio.h>
int main()
{
int i,j,index,n,a[10];
printf("enter a number");
scanf("%d",&n);
for(i=0;n!=0;i++)
{
a[i]=n%10;
n=n/10;
}
i=i-1;
printf("output\n");
for(;i>=0;i--)
{
for(j=i;j>=0;j--)
printf("%d\t",a[j]);
printf("\n");
}
return 0;
}

Is This Answer Correct ?    26 Yes 9 No

given integer number,write a program that displays the number as follows: First line :all digits ..

Answer / shams

#include <iostream>
#include<stdio.h>
#include<cstdlib>
#include<unistd.h>
#include<time.h>
#include<string.h>
using namespace std;
int main()
{
int i,b,j,index,n,a[10];
printf("enter a number");
scanf("%d",&n);
b=n;
for(i=0;n!=0;i++)
{
a[i]=n%10;
n=n/10;
}
b=i;
i=i-1;
printf("output\n");
for(;i>=0;i--)
{
for(j=i;j>=0;j--)
printf("%d\t",a[j]);
printf("\n");
for(int k=0;k<b-i;k++)
printf("\t");
}
return 0;
}

Is This Answer Correct ?    12 Yes 4 No

given integer number,write a program that displays the number as follows: First line :all digits ..

Answer / akashdeep

#include<stdio.h>
void main()
{
int a,count=0,b=1,c;
printf("enter a number
");
scanf("%d",&a);
c=a;
while(a>0)
{
count=count+1;
a=a/10;
}
for(int i=0;i<(count-1);++i)
{
b=b*10;
}
while(c>0)
{
printf("%d
",c);
c=c%b;
b=b/10;
}

}

Is This Answer Correct ?    8 Yes 2 No

given integer number,write a program that displays the number as follows: First line :all digits ..

Answer / md. wasifur rahman siyam

#include<stdio.h>
#include<conio.h>
int main()
{
int n,i=0,j,k=1,x,c=0,sum=0,a[100];
printf("
enter the number:");
scanf("%d",&x);
while(x!=0){
a[i++]=x%10;
x=x/10;
c++;
}
printf("
the digits are :
");
printf(" ");
for(j=c-1;j>=0;j--){
for(i=c-k;i>=0;i--){
printf("%d",a[i]);
}
printf("
");
printf(" ");
k=k+1;
}
getch();
return 0;
}

Is This Answer Correct ?    1 Yes 1 No

given integer number,write a program that displays the number as follows: First line :all digits ..

Answer / royalrdx

#include <stdio.h>
#include <math.h>

int main()
{
int n,a,count=0,b;
printf("Enter");
scanf("%d",&a);
n=a;
while(n>0){
count++;
n=n/10;
}

while (count>0)
{
b=pow(10,count);
printf("
%d
",a%b);
count--;
}
return 0;
}

Is This Answer Correct ?    1 Yes 1 No

given integer number,write a program that displays the number as follows: First line :all digits ..

Answer / pavan_mustyala

#include <stdio.h>

int main(int argc, char* argv[])
{
int num = 15;
int i = 1;
int j = 1;

for( ; i <= num; i++)
{
for( j = i; j <= num; j++)
{
printf("%-3d ",j);
}
printf("\n\n");
}

return 0;
}

Is This Answer Correct ?    4 Yes 14 No

given integer number,write a program that displays the number as follows: First line :all digits ..

Answer / mohit

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
printf("enter any number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=i;j<=n;j++)
{
printf("%d ",j);
}
printf("\n");
}
getch();
}

Is This Answer Correct ?    11 Yes 25 No

Post New Answer

More C Code Interview Questions

write a program in c to merge two array

2 Answers  


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

1 Answers  


You are given any character string. Find the number of sets of vowels that come in the order of aeiou in the given string. For eg., let the given string be DIPLOMATIC. The answer returned must be "The number of sets is 2" and "The sets are "IO and AI". Vowels that form a singleton set must be neglected. Try to post the program executable in gcc or g++ or in java.

3 Answers  


main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }

2 Answers   Persistent,


main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }

1 Answers  






write a origram swaoing valu without 3rd variable

2 Answers  


#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }

3 Answers   Hexaware,


main() { main(); }

1 Answers  


main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }

6 Answers  


What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


What is data _null_? ,Explain with code when u need to use it in data step programming ?

0 Answers   Abbott,


main() { char a[4]="HELLO"; printf("%s",a); }

3 Answers   CSC,


Categories