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
a number is perfect if it is equal to the sum of its proper
divisor..

 6 is perfect number coz its proper divisors are 1,2 and
three.. and 1+2+3=6...

a number is deficient if the sum of its proper divisor is
less than the number..
sample: 8 is deficient, coz its proper divisors are 1,2 and
4, and 1+2+4=7.

abundant number, if the sum of its proper divisor is greater
than the number..
sample..12 is abundant coz 1+2+3+4+6=16 which is geater than 12.

now write a program that prompts the user for a number, then
determines whether the number is perfect,deficient and
abundant..
 Question Submitted By :: Hmmm
I also faced this Question!!     Rank Answer Posted By  
 
  Re: a number is perfect if it is equal to the sum of its proper divisor.. 6 is perfect number coz its proper divisors are 1,2 and three.. and 1+2+3=6... a number is deficient if the sum of its proper divisor is less than the number.. sample: 8 is deficient, coz its proper divisors are 1,2 and 4, and 1+2+4=7. abundant number, if the sum of its proper divisor is greater than the number.. sample..12 is abundant coz 1+2+3+4+6=16 which is geater than 12. now write a program that prompts the user for a number, then determines whether the number is perfect,deficient and abundant..
Answer
# 1
#include<conio.h>
#include<stdio.h>
int f(int x)
{	int i,c,a=0;
	for(i=1;i<x;i++)
	{       c=x%i;
		if(c==0)
		     a+=i;
	}
	return a;
}
void main()
{  int x;
   clrscr();
   printf("\nenter a integer number:\n");
   scanf("%d",&x);
   printf("%d",f(x));
   if(f(x)==x)
	printf("\nthis number is prefect");
   if(f(x)>x)
	printf("\nthis number is abundant");
   if(f(x)<x)
	printf("\nthis number is deficient");
   getch();
}

 
Is This Answer Correct ?    1 Yes 2 No
Samim
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
plssssss help !!....using array.. turbo c.. create a program that will accept number of words to be consored. .a word must not exceed 10 characters long .the text to be entered will be no longer than 200 characters .there will be no 10 words example: enter number of words to be censor: 5 enter words to censor: windows office microsoft bill gates enter text to censor: bill gates founded microsoft and makes office and windows sample output: <consored> <censored> founded <censored> and makes <censored> and <censored>  1
void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..  1
Define function ?Explain about arguments? Geometric-Software2
write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]  2
what is meant by the "equivalence of pointers and arrays" in C? Satyam3
When is an interface "good"?  1
what information does the header files contain? BSNL5
what is the difference between normal variables and pointer variables.............. Satyam7
Explain what?s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?  1
1)which of following operator can't be overloaded. a)== b)++ c)?! d)<= Siemens10
how memory store byte Huawei3
Can we write a program without main() function?  9
main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); } output? Ramco6
Dear Sir, we are required the bubble sorting programs Regs Prem  1
#ifdef TRUE int I=0; #endif main() { int j=0; printf("%d %d\n",i,j); } ADITI2
Is main() function predfined or userdefined?  7
how many header file is in C language ?  14
What is macro? IBM4
What is #pragma directive?how it is used in the program? what is its advantages and disadvantages?  1
how to make c program without a libary? e.g.#include<stdio.h> libary is not in c progaram.  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