Powered by Blogger.

Sunday, March 24, 2013

24.How we are find out second in year:


#include<stdio.h>
int main()
{
    printf("number of seconds in a year:\n");
    printf("%f\n",60.0*60.0*24.0*365.0);
    return 0;
}

23.How computes the volume of a cube:


#include<stdio.h>
int main()
{
    int len,width,height,cube;
    printf("Enter a len of your choice:\n");
    scanf("%d",&len);
    printf("Enter a width of your choice:\n");
    scanf("%d",&width);
    printf("Enter a hright of your choice:\n");
    scanf("%d",&height);
    cube=len*width*height;
    printf("cube=%d",cube);
    return 0;
}

Tuesday, March 19, 2013

acm 10302 summation of polynomials:

#include<stdio.h>
int main()
{
    long double x,sum;
    while(scanf("%Lf",&x)==1)
    {
        sum=(x*(x+1)*x*(x+1))/4;
        printf("%.0Lf\n",sum);
    }
    return 0;
}

acm 12468 Zapping:

#include<stdio.h>
int main()
{
    int a,b,c,t;
    while(scanf("%d %d",&a,&b))
    {
        if(a==(-1)&&b==(-1))
        break;
        if(a>b)
        c=a-b;
        else
        c=b-a;
        if(c>50)
        {
            c=100-c;
        }
        printf("%d\n",c);
    }
    return 0;
}

22.How we are print odd and even number by using for loop?

#include<stdio.h>
int main()
{
    int i,n;
    printf("Enter your choice number:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        if(i%2==0)
        printf("%d\n",i);
        else
        printf("%d\t",i);
    }
    return 0;
}

21.How we are print even number by using for loop:

#include<stdio.h>
int main()
{
    int i,n;
    printf("Enter your choice number:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        if(i%2==0)
        printf("%d\t",i);
    }
    return 0;
}

20.How we are print odd number by using for loop:

#include<stdio.h>
int main()
{
    int i,n;
    printf("Enter your choice number:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        if(i%2!=0)
        printf("%d\t",i);
    }
    return 0;
}