ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Code Snippets >> Programming Code >> C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions (401)
 C++ Code interview questions  C++ Code Interview Questions (121)
 VC++ Code interview questions  VC++ Code Interview Questions (2)
 Java Code interview questions  Java Code Interview Questions (58)
 Dot Net Code interview questions  Dot Net Code Interview Questions (113)
 Visual Basic Code interview questions  Visual Basic Code Interview Questions (8)
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions (37)
Question
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
 Question Submitted By :: C-Code
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
#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 ?    12 Yes 3 No
Jickson
 
Answer
# 2
#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 ?    9 Yes 3 No
Shams
 
 
 
Answer
# 3
#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 ?    3 Yes 0 No
Shams
 
Answer
# 4
#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 ?    6 Yes 9 No
Mohit
 
Answer
# 5
#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 ?    2 Yes 7 No
Pavan_mustyala
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); }   10
Extend the sutherland-hodgman clipping algorithm to clip three-dimensional planes against a regular paralleiepiped IBM 1
write the function. if all the character in string B appear in string A, return true, otherwise return false. Google 11
main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }   1
Write a routine that prints out a 2-D array in spiral order Microsoft 3
main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world” HCL 5
void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }   1
main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above HCL 2
code of a program in c language that ask a number and print its decremented and incremented number.. sample output: input number : 3 321123 HCL 1
Is the following code legal? void main() { typedef struct a aType; aType someVariable; struct a { int x; aType *b; }; }   1
main() { char a[4]="HELL"; printf("%s",a); } Wipro 3
Predict the Output: int main() { int *p=(int *)2000; scanf("%d",2000); printf("%d",*p); return 0; } if input is 20 ,what will be print   2
 
For more C Code Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright © 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com