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 ?    4 Yes 1 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 ?    7 Yes 1 No
Rajesh Kumar S
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
difference between my-strcpy and strcpy ? Geometric-Software3
What is an object?  2
fn f(x) { if(x<=0) return; else f(x-1)+x; } HCL3
Which is not valid in C? 1) class aClass{public:int x;} 2) /* A comment */ 3) char x=12;  4
what is c? Tech-Mahindra4
read the folllowing code # define MAX 100 # define MIN 100 .... .... if(x>MAX) x=1; else if(x<MIN) x=-1; x=50; if the initial value of x=200,what is the vlaue after executing this code? a.200 b.1 c.-1 d.50 TCS2
f=(x>y)?x:y a) f points to max of x and y b) f points to min of x and y c)error HCL3
what is the difference between const volatile int i & volatile const int j; HCL1
What should be keep precautions while using the recursion method?  1
In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT IBM1
write a C code to reverse a string using a recursive function, without swapping or using an extra memory. Motorola2
What is structure padding ? HP1
What is the difference b/w main() in C language and main() in C++.  3
Why doesn't C have nested functions?  1
How to implement variable argument functions ? HP1
int main() { int *p=new int; *p=10; del p; cout<<*p; *p= 60; cout<<*p; } what will be the output & why? TCS3
identify the in correct expression a.a=b=3=4; b.a=b=c=d=0; float a=int b=3.5; d.int a; float b; a=b=3.5; TCS4
two progs are given. one starts counting frm 0 to MAX and the other stars frm MAX to 0. which one executes fast. Verifone3
Explain what?s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?  1
#define DCHAR char* typedef char* TCHAR; if using these following variables will be declared like DCHAR ch1, ch2; TCHAR ch3, ch4; then what will be types of ch1, ch2, ch3 and ch4? NDS1
 
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