0% found this document useful (0 votes)
2 views5 pages

Meh

The document contains four C programming questions, each focusing on different computational tasks. Question 1 calculates the number of digits, sum, and product of digits in a number, and checks if the sum of the digits and their product equals the original number. Question 2 checks if a number is a Dudeney number, Question 3 sums prime numbers within a given range, and Question 4 finds the closest Fibonacci number to a given input.

Uploaded by

Aadarsh Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Meh

The document contains four C programming questions, each focusing on different computational tasks. Question 1 calculates the number of digits, sum, and product of digits in a number, and checks if the sum of the digits and their product equals the original number. Question 2 checks if a number is a Dudeney number, Question 3 sums prime numbers within a given range, and Question 4 finds the closest Fibonacci number to a given input.

Uploaded by

Aadarsh Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

QUESTION 1

#include<stdio.h>

int main(){

int n,count=0,m,sum=0,prod=1,r,total,s;

printf("enter the number:-");

scanf("%d",&n);

m=n;

s=n;

while(n!=0){

n=n/10;

count+=1;

printf("the number of digits in the number is:-%d",count);

while(m!=0){

r=m%10;

sum+=r;

prod*=r;

m=m/10;

total=sum+prod;

if (s==total){

printf("\nNumber matched and the number is %d",s);

else{

printf("\n number not matched %d",0);


}

return 0;

}
QUESTION 2

#include<stdio.h>

int main(){

int n,m,sum=0,r,prod;

printf("enter the number to check:-");

scanf("%d",&n);

m=n;

while(n!=0){

r=n%10;

sum+=r;

n=n/10;

prod=(sumsumsum);

if (prod==m){

printf("Its a Dudeney number");

else{

printf("its not a Dudeney number");

return 0;

}
QUESTION 3

#include<stdio.h>

int main(){

int n,m,flag,sum=0;

printf("enter the range in between you want to search:-");

scanf("%d%d",&n,&m);

for (n; n<=m;n++){

flag=0;

for (int x=2;x<=n/2;x++){

if (n%x==0){

flag=1;

break;

if (flag==0){

sum+=n;

printf("the sum of prime number till %d is:-",sum);

return 0;

}
QUESTION 4

#include<stdio.h>

int main(){

int n,x=0,y=1,z;

printf("enter the number for the fibonacci number:-");

scanf("%d",&n);

while (y<=n){

z=y;

y=x+y;

x=z;

if ((y-n)>(n-x)){

printf("the fibonacci number is:-%d",x);

else{

printf("the fibonacci number is:-%d",y);}

return 0;

You might also like