Month: September 2012

Write a program to a number of Factorial .

Solution :- 
1st way:-

#include<stdio.h>
int main(){
int i,f=1,num;
printf(“Enter a number : “);
scanf(“%d”,&num);
for(i=1;i<=num;i++)
f=f*i;
printf(“Factorial of %d is : %d”,num,f);
return 0;
}
2nd way:-
#include<stdio.h>
int main()
{
int i=1,f=1,num;
printf(“Enter a number: “);
scanf(“%d”,&num);
while(i<=num){
f=f*i;
i++;
}
printf(“Factorial of %d is: %d”,num,f);
return 0;
}


Sample Input

Sample Output

Enter a number : 5
Enter a number : 10
Factorial of 5 is : 120
Factorial of 5 is : 3628800
At First you can try to solve this problem if you can’t than see this code & find what’s your problem . If you copy paste this code you could not improve yourself in programming .
Posted by Shipu Ahamed in Basic Programming, Math, 0 comments

Uva 136 – Ugly Numbers

Problem Link

Solution :

   Hints                    : http://www.algorithmist.com/index.php/UVa_138

 

Posted by Shipu Ahamed in Programming, Uva, 0 comments

Write a program to Characters and number ASCII value in your input .

Solution :-



#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    int n;
    char c;
    while(1)
    {
        scanf(“%c”,&c);
        getchar();
        n=toascii(c);
        printf(“%dn”,n);
    }
    return 0;
}


At First you can try to solve this problem if you can’t than see this code & find what’s your problem . If you copy paste this code you could not improve yourself in programming .
Posted by Shipu Ahamed in Basic Programming, 0 comments

Uva 11854 – Egypt

Problem:-http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2954

Solution :-

#include<stdio.h>
int main()
{
long a,b,c,d,e,f;
while(scanf(“%ld %ld %ld”,&a,&b,&c)==3)
{
d=a*a;
e=b*b;
f=c*c;
if(a!=0 || b!=0 || c!=0)
 {
 if(f==d+e)
 printf(“rightn”);
 else if(d==e+f)
 printf(“rightn”);
 else if(e==d+f)
 printf(“rightn”);
 else
 printf(“wrongn”);
 }
}
return 0;
}
At First you can try to solve this problem if you can’t than see this code & find what’s your problem . If you copy paste this code you could not improve yourself in programming .
Posted by Shipu Ahamed in Programming, Uva, 0 comments

Uva 10432 – Polygon Inside A Circle

Problem Link

Solution :-

   Hints                    : http://www.algorithmist.com/index.php/UVa_10432

 

Posted by Shipu Ahamed in Programming, Uva, 0 comments

Uva 494 – Kindergarten Counting Game

Problem Link

Solution :-

 

Posted by Shipu Ahamed in Programming, Uva, 2 comments

Uva 10499 – The Land of Justice

Problem Link

Solution :-

 

Posted by Shipu Ahamed in Programming, Uva, 0 comments

Uva 10302 – Summation of Polynomials

Problem Link

Solution :-

 

Posted by Shipu Ahamed in Programming, Uva, 0 comments

Uva 11934 – Magic Formula

Problem Link

Solution :-

 

Posted by Shipu Ahamed in Programming, Uva, 0 comments

Uva 12289 – One-Two-Three

Problem Link

Solution :-

 

Posted by Shipu Ahamed in Programming, Uva, 0 comments