#include<stdio.h>
void main()
{
int a,b,c;
printf("Enter numbers...");
scanf("%d%d%d",&a,&b,&c);
if((a>=b)&&(a>=c))
{
if(b>=c)
{
printf("\n Descending order : %d %d %d",a,b,c);
printf("\n Ascending order : %d %d %d",c,b,a);
}
else
{
printf("\n Descending order : %d %d %d",a,c,b);
printf("\n Ascending order : %d %d %d",b,c,a);
}
}
else if((b>=a)&&(b>=c))
{
if(a>=c)
{
printf("\n Descending order : %d %d %d",b,a,c);
printf("\n Ascending order : %d %d %d",c,a,b);
}
else
{
printf("\n Descending order : %d %d %d",b,c,a);
printf("\n Ascending order : %d %d %d",a,c,b);
}
}
else if((c>=a)&&(c>=b))
{
if(a>=b)
{
printf("\n Descending order : %d %d %d",c,a,b);
printf("\n Ascending order : %d %d %d",b,a,c);
}
else
{
printf("\n Descending order : %d %d %d",c,b,a);
printf("\n Ascending order : %d %d %d",a,b,c);
}
}
}
Kindly correct the logic, its in reverse order.
What is incorrect? its showing both series correctly.
sir i want logic to find the given no. is prime or not
Hi Dheeraj that program is already on this website, just use the search option. You will find it here
#include
#include
void main()
{ clrscr();
int a=1,s=0,s1=0,f=0;
cout<>a;
for(int i=2;i<a/2;i++)
{ if(a%i==0)
{ f=1;
break;
}
}
if(f==1)
cout<<":::::::::::::::::::::::::::::Not Prime:::::::::::::::::::::::::::::::";
if(f==0)
cout<<"::::::::::::::::::::::::::::::::::Prime:::::::::::::::::::::::::::::::";
getch();
}
In the program of printing ascending and descending of 3 numbers…. you have made a mistake in all the printf statements i.e.,you are printing ascending order but you named it as descending…… ascending means printing numbers from small to big whereas u r printing the numbers big to small
Juz change d condition… Alone .. ull get d crt program
i’ve made the exact program in the turbo c compiler and its working perfectly fine….there is no problem in the program.. u must have interchanged the values of a,b,c in the scanf statement..
hi Aditya, rectified!! thanks for notifying :).
thank u sir , for putting such problems in website
it helped me for exams
Thanks, Pavan, do share the website and Android App with your friends
great doing prashant sir
want php coding in array forloop,and more
THANK U
IT WAS VERY USEFUL
Thank you Niharika, you can learn these programs in video format now, check out https://www.kodegod.com/, registration is absolutely free, do share it with your friends too. Happy learning!