ALLInterview.com :: Home Page KalAajKal.com
 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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
write a program to check whether a given integer is a strong
number or not?
[Hint:
145=1!+4!+5!
   =1+24+120
   =145]
 Question Submitted By :: Vasu
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]
Answer
# 1
#include<stdio.h>
void main()
{
int x,y,z,sum=0,h=1,t;
int factorial (int g, int k);
printf("enter a value to check whether it is strong 
number...\n");
scanf("%d",&x);
printf("\nthe entered value is:::: %d \n ",x);
t=x;
while(x>0)
{
y=x%10;
x=x/10;
z=factorial(y,h);
sum=sum+z;
}	
if(sum==t)
{
printf("\n %d is a strong no:\n",t);
}
else
{
printf("\n %d is not a strong  no:\n",t);
}
}	
int factorial (int g, int k)
{
while(g>=1)
{
	k=k*g;
	g=g-1;
}
return k;
}
 
Is This Answer Correct ?    7 Yes 3 No
Mathew Varghese
 
  Re: write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]
Answer
# 2
void main()  

 { 
 int n,t,f=1,s=0,num;
 printf("enter the num \t:");
 scanf("%d",&n);
 num=n;
 while(num)
 {
	 t=num%10;
	 f=1;
	 while(t)
	 {
		 f=f*t;
		 t--;
	 }
	 s=s+f;
	 num=num/10;
 }
if(n==s)
printf("%d is a strong number",n);
else
printf("%d is not a strong number",n);
}
 
Is This Answer Correct ?    13 Yes 3 No
Rajesh Kumar S
 
 
 
  Re: write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]
Answer
# 3
#include<stdio.h>
int main()
{
  int n = 145;
  int i,sum=0,temp;
  temp = n;
  while(n>1)
  {
    n=n%10;
    sum = sum+fact(n);
    printf("%d",sum);
  }
  if(temp == sum)    
    printf("Given no is STRONG number\n");
}
int fact(int a)
{
  int i=1,fact=1;
  fact = i*fact(--i);
  return fact;
}
 
Is This Answer Correct ?    1 Yes 1 No
Dally
 
  Re: write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]
Answer
# 4
int fact(int f)
{
if(f==1||f==0)
   return 1;
else
    return(f*fact(f-1));
}
main()
{
   int n,i,j,s=0;
    printf("enter the number");
    scanf("%d",&n);
    i=n;
    while(n!=0)
    {
      j=n%10;
      s=s+fact(j);
      n=n/10;
     }
     if(i==s)
            printf("strong number");
     else
            printf("not a strong number");
}
 
Is This Answer Correct ?    0 Yes 2 No
Valli
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Can we include one C program into another C program if yes how? Infosys4
What is external and internal variables What is dynamic memory allocation what is storage classes in C  2
#define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs? Ramco4
15.what is the disadvantage of using macros? 16.what is the self-referential structure? 17.can a union be self-referenced? 18.What is a pointer? 19.What is the Lvalue and Rvalue? 20.what is the difference between these initializations? 21.Char a[]=”string”; 22.Char *p=”literal”; 23.Does *p++ increment p, or what it points to?  1
int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+zap(n-1); } then the call zap(6) gives the values of zap [a] 8 [b] 9 [c] 6 [d] 12 [e] 15 Wipro8
why we shiuld use main keyword in C  5
how to convert binary to decimal and decimal to binary in C lanaguage  4
Write a C function to search a number in the given list of numbers. donot use printf and scanf Honeywell6
Write a C program that computes the value ex by using the formula ex =1+x/1!+x2/2!+x3+3!+………….  1
12. Look at the Code: main() { int a[]={1,2,3},i; for(i=0;i<3;i++) { printf("%d",*a); a++; } } Which Statement is/are True w.r.t the above code? I.Executes Successfully & Prints the contents of the array II.Gives the Error:Lvalue Required III.The address of the array should not be changed IV.None of the Above. A)Only I B)Only II C)II & III D)IV Accenture4
difference between i++* and *++i IBM3
How the C program can be compiled? HP7
what is the difference between declaration and definition of a variable or function ?  2
Identify the correct argument for the function call fflush () in ANSI C: A)stdout B)stdin C)stderr D)All the above Accenture3
Write a program to print this triangle: * ** * **** * ****** * ******** * ********** Don't use printf statements;use two nested loops instead. you will have to use braces around the body of the outer loop if it contains multiple statements.  2
can we print any string in c language without using semicolon(;)(terminator) in whole program.  6
Explain what?s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?  1
What does extern mean in a function declaration?  2
Why is conio.h not required when we save a file as .c and use clrscr() or getch() ?  2
dibakar & vekatesh..uttejana here..abt ur reply for in place reversal of linked list..wats p stands for there?  1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com