Printing Strong Numbers in the given Range | C Language Tutorial | Mr. Srinivas naresh i technology c language

by sdfghjWWErtykjbv



Printing Strong Numbers in the given Range
C Language Tutorial Videos | Mr. Srinivas
** For Online Training Registration: ? Call: +91-8179191999

? Visit Our Website for Classroom Training:

? For Online Training:

————————–

? About NareshIT:

“Naresh IT is having 14+ years of experience in software training industry and the best Software Training Institute for online training, classroom training, weekend training, corporate training of Hadoop, Salesforce, AWS, DevOps, Spark, Data Science, Python, Tableau, RPA ,Java, C#.NET, ASP.NET, Oracle, Testing Tools, Silver light, Linq, SQL Server, Selenium, Android, iPhone, C Language, C++, PHP and Digital Marketing in USA,Hyderabad, Chennai and Vijayawada,Bangalore India which provides online training across all the locations

See also  Top_10 नेपालको Technical Youtube Channel #Top_10_Best_Youtube Technology Channel Of Nepal #Nepal_GS technology channel

————————–

? Our Online Training Features:
1.Training with Real-Time Experts
2.Industry Specific Scenario’s
3.Flexible Timings
4.Soft Copy of Material
5. Share Videos of each and every session.

————————–

Please write back to us at us.training@nareshit.com/online@nareshit.com or Call us at USA:

See also  How AI is driving a future of autonomous warfare | DW Analysis technology ai

+1404-232-9879 or India: +918179191999

** Check The Below Links**
? For Course Reg:
? Subscribe to Our Channel:
? Circle us on G+:
? Like us on Facebook:
? Follow us on Twitter:
? Follow us on Linkedin:

? Follow us on Instagram: .

Images related to the topic naresh i technology c language

Printing Strong Numbers in the given Range | C Language Tutorial | Mr. Srinivas

Printing Strong Numbers in the given Range | C Language Tutorial | Mr. Srinivas

Search related to the topic Printing Strong Numbers in the given Range | C Language Tutorial | Mr. Srinivas

#Printing #Strong #Numbers #Range #Language #Tutorial #Srinivas
Printing Strong Numbers in the given Range | C Language Tutorial | Mr. Srinivas
naresh i technology c language
See all the latest ways to make money online: See more here
See all the latest ways to make money online: See more here

You may also like

47 comments

Naresh i Technologies 26/09/2021 - 1:31 AM

Please Comment, Subscribe and Click Bell🔔🔔🔔 Icon for More Updates. To learn software course from our experts please register here for online training: https://goo.gl/HIB0wL

Reply
Udit Sahoo 26/09/2021 - 1:31 AM

You prove we shouldn't judge a book by it's cover.

Reply
SAIKUMAR KISSTALA 26/09/2021 - 1:31 AM

I think
for(n=1;n<=limit;n++)
Is correct
#Naresh I technologies

Reply
vishal vaishnav 26/09/2021 - 1:31 AM

sir starting for loop in not i<=limit but n<=limt ayegana sir please rply

Reply
Venkatesh Jajula 26/09/2021 - 1:31 AM

#include <stdio.h>

void main()
{
int n,i,j,rem,temp;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
temp=i;
int sum=0;
while(temp>0)
{
int fact=1;
rem=temp%10;
for(j=rem;j>0;j–)
{
fact*=j;
}
sum+=fact;
temp=temp/10;
}
if(i==sum)
printf("%dn",i);
}
}

Reply
parthik sonagara 26/09/2021 - 1:31 AM

/*strong number in given range*/

#include <stdio.h>

int main()
{
long int limit,r,n,temp,fact,i,sum=0;
printf("enter the value of the limit=");
scanf("%ld",&limit);

for(n=1;n<=limit;n++)
{
sum=0;
temp=n;
while(n>0)
{
r=n%10;
fact=1;
for(i=r; i>=1;i–)
{
fact=fact*i;
}
sum=fact+sum;
n=n/10;
}
n=temp;
if(n==sum)
{
printf("strong numbers in given range are =%ld n",n);
}

}

return 0;
}

Reply
Vishal V 26/09/2021 - 1:31 AM

Sir here u didn't store n value to temp

Reply
Praveentechintelugu 26/09/2021 - 1:31 AM

there is a mistake in the code.
it should be like this
//printing strong number in the given range….strong number:(sum of the idividual factorial of individual digits is called strong number)

#include<stdio.h>

void main()

{

int sum=0,fact=1,r=0,temp,limit;

printf("enter lmit:");

scanf("%d",&limit);

for(int n=1;n<=limit;n++)

{ temp=n;

while(n>0)

{

r=n%10;

if(r!=0)

{

while(r!=0)

{

fact=fact*r;

r–;

}

sum=sum+fact;

}

fact=1;

n=n/10;

}

n=temp;

if(n==sum)

{

printf("%d ",sum);

}

sum=0;

}

}

Reply
ENG20CS0074 _chetan.r 26/09/2021 - 1:31 AM

Where is that video what is a strong number plzzzzzzzzz anyone replyyyyyyyyyyy😭😭😭

Reply
suhas g 26/09/2021 - 1:31 AM

sir why did we use count++?

Reply
IRFAN Irfu 26/09/2021 - 1:31 AM

#include<stdio.h>
int main()
{

int fact,i,n,sum,r,temp,start,end;
printf("enter rangen");
scanf("%d %d",&start,&end);
for(n=start;n<=end;n++)
{ sum=0;
temp=n;
while(n>0)
{ fact=1;
r=n%10;
for(i=r;i>=1;i–)
{
fact=fact*i;
}
sum=sum+fact;
n=n/10;
}
n=temp;
if(n==sum)
printf("%d ",n);

}
}
// strong numbers in the given range

Reply
DEEKSHANT GOYAL 26/09/2021 - 1:31 AM

Here is the complete code:
#include<stdio.h>
main()
{

int n,r,sum=0,i,t, temp;
printf("enter the value of n");
scanf("%d",&n);
temp=n;
while(n>0)
{
r=n%10;
t=r;
n=n/10;
for(i=1;i<t;i++)
{
r=r*i;
}
sum=sum+r;
}
if(sum==temp)
printf("it is a strong number");

else
printf("it is not");
}

Reply
Smita Mohite 26/09/2021 - 1:31 AM

solution:-
#include<stdio.h>

void main()

{

int limit,n,i,r,sum,fact,tmp;

printf("enter the limits=");

scanf("%d",&limit);

for(n=1;n<=limit;n++)

{

sum = 0;

tmp = n;

while(n>0)

{

r=n%10;

fact=1;

for(i=r;i>=1;i–)

{

fact=fact*i;

}

sum=sum+fact;

n=n/10;

}

n=tmp;

if(n==sum)

{

printf("%d is strong numbern",n);

}else

{

printf("%d is not the strong numbern",n);

}

}

}

if we put the limit=145 then it will give strong number between 1 to 145.

Reply
Dhruv Jain 26/09/2021 - 1:31 AM

here is the correct program
//program to check whether a number is a strong number or not in a given limit

#include <stdio.h>

main()

{

int n, r, i, sum, fact, k, limit;

printf("Enter a value: ");

scanf("%d", &limit);

for(n=1; n<=limit; n++)

{

sum = 0;

k=n;

while(k>0)

{

r=k%10;

k=k/10;

fact = 1;

for(i=1; i<=r; i++)

{

fact = fact*i;

}

sum = sum + fact;

}

if(sum == n)

{

printf("%d is a strong numbern", n);

}

else

{

printf("%d is not a strong numbern", n);

}

}

}

Reply
Vaibhav Garg 26/09/2021 - 1:31 AM

You didn't stored n value in temp.. So whenever you check in last while printing the number.. No number will be perfect number.. As n's value would be 0

Reply
AKHILA KS 26/09/2021 - 1:31 AM

Sir forgot to say to insert temp value for n

Reply
sai dikshith 26/09/2021 - 1:31 AM

Hey guys i have a pic where you all can find sequence and order of the
c-programming videos by Naresh sir …how many of you guys need it..

Reply
SCORPUS GAMING 26/09/2021 - 1:31 AM

int main()
{
int r,n,fact,sum=0,temp;
printf("enter the valuen");
scanf("%d",&n);
temp=n;
While(n>0)
{
r=n%10;
fact=1;
for(int i=r ; i>=1 ; i–)
{
fact=fact*i ;
}
sum=sum+fact ;
n=n/10;
}
n=temp;
if(n==sum)
{
printf("it's a strong numbern",n);
}
else
printf ("nikal lavde");
}
Thinks should go positive from here

Reply
likhitha shetty 26/09/2021 - 1:31 AM

Sir u told to replace the read with printf and scanf what we should write in printf and scanf

Reply
A kan 26/09/2021 - 1:31 AM

The one who is reading my comment can run this program and tell me what's wrong with this program ?
why does it give me wrong output ?
#include<stdio.h>
int main()
{
//declaring variables
int re; //remainder
int copy;
int i; //counter
int num;
int fact; //factorial
fact=1;
int sum; //sum
sum=0;
//taking input
printf("enter your number:n");
scanf("%d",&num);
copy=num; //storing the value of num to copy variable

while(copy!=0)
{
re=copy%10;
for(i=1;i<=re;i++);
{
fact=fact*i;

}
sum=sum+fact;
fact=1;
copy=copy/10;
}
if(sum==num)
printf("%d is the strong numbern",num );
else
printf("%d is not strong numbern",num);
return 0;
}
plz help me …

Reply
ARJUN V 26/09/2021 - 1:31 AM

Sir the value of n is changing ,so temp variable is required?

Reply
T Deepak reddy 26/09/2021 - 1:31 AM

i refered many codes not only this but different logics,i never felt i got it ,complete concept
but you made it clear sir, thank you so much keep going

Reply
VENKATESWARA REDDY 26/09/2021 - 1:31 AM

when n becomes 0 in while loop then later if condition has n==sum here error ,,temp variable is need to be use there

Reply
pranay varma 26/09/2021 - 1:31 AM

HERE IS THE CODE FOR STRONG NUMBERS:
#include<stdio.h>

main()

{

int i,n,r,fact,sum=0,temp,limit;

printf("enter the limit ");

scanf("%d",&limit);

for(n=1;n<=limit;n++)

{

temp=n;

sum=0;

while(n>0)

{

fact=1;

r=n%10;

for(i=1;i<=r;i++)

{

fact=fact*i;

}

sum=sum+fact;

n=n/10;

}

n=temp;

if(sum==n)

{

printf("%d strong number n",n);

} else

{

printf("%d not a strong numbern",n);

}

}

}//your welcome

Reply
Amit Jaiswal 26/09/2021 - 1:31 AM

You have to store n value in another variable before loop

Reply
all is well 26/09/2021 - 1:31 AM

there is a mistake in the program
n need to be replaced
check this solution:
for(j=1;j<=limit;j++)
{
n=j;
…..
……..
}
if(j==sum)
{
printf("%d strong",j);
}

Reply
Mohammed Zidan 26/09/2021 - 1:31 AM

Thank You

Reply
Pavan Kalyan Vakiti 26/09/2021 - 1:31 AM

Sir
While loop will execute until the statement goes wrong. n>0 is always correct how will loop terminate

Reply
Samrat Chatterjee 26/09/2021 - 1:31 AM

sir help me code is not working after compile

Reply
Samrat Chatterjee 26/09/2021 - 1:31 AM

first for loop i did not understand repeat the explanation

Reply
Samrat Chatterjee 26/09/2021 - 1:31 AM

sir in first for loop you passed i in condition checking i or n it wiil be

Reply
VICTOR KUWANDIRA 26/09/2021 - 1:31 AM

Not working

Reply
Sanchit Gupta 26/09/2021 - 1:31 AM

FOR ALL THOSE WHO ARE FACING PROBLEM IN THIS CODE
THIS IS THE CORRECT CODE FOR THIS PROGRAM:

#include <stdio.h>

#include <conio.h>

int main()

{

long int n, limit, r, i, temp, fact, sum=0;

printf("Enter the limit:");

scanf("%ld", &limit);

for(n=1; n<=limit; n++)

{

temp=n;

sum=0;

while(n>0)

{

r=n%10;

fact=1;

for(i=r; i>=1; i–)

{

fact=fact*i;

}

sum=sum+fact;

n=n/10;

}

n=temp;

if(n==sum)

{

printf("%ld is a strong numbern", n);

}

}

getch();

}

FIRST COPY – PASTE THE ABOVE CODE AND TRY IN YOUR IDE
SURELY IT WOULD WORK.

Reply
BossySmaxx Hex 26/09/2021 - 1:31 AM

here's the solution(with correction):-

#include<stdio.h>
#include<conio.h>
void main()
{
long int i,j,range,index,sum=0,fact=1,temp;
clrscr();
printf("Enter any number here:");
scanf("%ld",&range);
for(i=1;i<=range;i++)
{
temp=i;
sum=0;
while(temp!=0)
{
fact=1;
index=temp%10;
for(j=1;j<=index;j++)
{
fact=fact*j;
}
temp=temp/10;
sum=sum+fact;
}

if(sum==i)
{
printf("%ldn",i);
}
}
getch();
}

I've tried it so many times and it giving me the perfect and correct result. So you've to try it too.

Reply
BossySmaxx Hex 26/09/2021 - 1:31 AM

I've just stored the i's value in temp var where i stores its value in temp and used temp to prevent loop infinite occurrence. and temp gets reset everytime when loop starts from beginning. That's all. The snippet is in the next comment.

Reply
Slobodan Tajisic 26/09/2021 - 1:31 AM

# include <stdio.h>
# include <stdlib.h>

int fact(int n) {
int k, f = 1;
for (k = 1; k <= n; k++) {
f = f * k;
}
return f;
}

int main(int argc, char** argv) {

long low, up, i, temp, sum, numbers[100];
int strong, factoriel, rem;

printf("Enter lower limit!n");
scanf("%ld", &low);
printf("Enter upper limit!n");
scanf("%ld", &up);

for (i = low; i <= up; i++) {
sum = 0;
temp = i;
while (temp > 0) {
rem = temp % 10;
factoriel = fact(rem);
sum = sum + factoriel;
temp = temp / 10;
}
if(sum == i){
numbers[strong] = i;
strong++;
}
}
if(strong == 0)
printf("nNo strong numbers between %ld and %ldn", low, up);
else{
printf("nStrong numbers between %ld and %ld are :nn", low, up);
for(i = 0; i < strong; i++)
printf("numbers[%ld] je %ldn", i, numbers[i]);
}

return (EXIT_SUCCESS);
}

Reply
VenkY V7 Plus 26/09/2021 - 1:31 AM

It is not working.since, there is no temporary value,sir please tell us how to store temporary value for like those numbers that are in a given range.

Reply
Subhadeep Sarkar 26/09/2021 - 1:31 AM

#include<stdio.h>
void main()
{
int limit,n,r,fact,i,temp,sum=0;
printf("Enter limit");
scanf("%d",&limit);
for(n=1;n<=limit;n++)
{temp=n;
sum=0;

while(n>0)
{
r=n%10;
fact=1;
for(i=r;i>=1;i–)
{
fact=fact*i;
}
sum=sum+fact;
n=n/10;

}
n=temp;
if(sum==n)
{
printf(" %d is strong no n",n);
}

}
}

Reply
Anubhav Roy 26/09/2021 - 1:31 AM

Great illustration

Reply
Souhardya 26/09/2021 - 1:31 AM

sir explain more

Reply
Engineering Fun 26/09/2021 - 1:31 AM

There is need of temp variable as if(sum==temp) instead of n..

Reply
naga sai dileep marisetty 26/09/2021 - 1:31 AM

program is not working can any body modify the code

Reply
༻💗Ⱥʂհą💗༺ 26/09/2021 - 1:31 AM

I think we need to assign 'n' value to some 'temp' variable before while loop, and we have to check with sum .

Reply
prasad solleti 26/09/2021 - 1:31 AM

its not working we use one temparary variable because n==sum , also its not working
can any one help me

Reply
Mohit192000 26/09/2021 - 1:31 AM

not working

Reply
rajesh be 26/09/2021 - 1:31 AM

Nice strong explanation sir for strong num program thank u so much sir

Reply
Wolverine Logan 26/09/2021 - 1:31 AM

The correct program is as bellow:
int main()
{
int n, i, count=0;
printf("Enter any integer to check whether it is prime number or not:n");
scanf("%d",&n);
for(i=2; i<=n/2; i++)
{
if(n%i==0)
{
count=1;
}
}
if(count==0)
printf("%d is a prime number",n);
else
printf("%d is not a prime number",n);
return 0;
}

Reply

Leave a Comment