I wrote something about a funny program yesterday,and the program sent by friend Sriram was nevertheless good,but I would say it lacked efficiency.So I thought of a way the computer would be made to do less calculations and improve the speed;my idea was to reduce the number of iterations by avoiding the procedure of checking each and every four digit number for the condition.Instead the program could check if the second digit was greater than the first,then only move on.Likewise using nested for loops the program's efficiency could be improved.Here's the program I wrote:
#include
#include
void main()
{
int n1,n2,n3,n4,count=0;
clrscr();
for(n1=1;n1<=9;n1++)
for(n2=(n1+1);n2<=9;n2++)
for(n3=0;n3
for(n4=(n3+1);n4<=9;n4++)
{printf("%d%d%d%d\n",n1,n2,n3,n4);count++;}
printf("Count = %d",count);
getch();
}
Ahem!
My pals
Categories
- 1 equals 2 (1)
- 33 reasons (1)
- Brain (1)
- cool Illusion (1)
- Funny Photos (1)