Monday, April 15, 2013

Find the Cosign value in C using Math function

Write a program to find the value of Cosign in C 



#include<stdio.h>
#include<math.h>
#define pi 3.1416
#define MAX 180
void main()
{
    int angel;
    float a=0.0,b=0.0;
    printf("Enter the value of Angel: ");
    scanf("%d",&angel);
    if(angel<=MAX)
    {
        a=(pi/MAX)*angel;
        b=cos(a);
        printf("The vaule of %d is: %0.4f",angel,b);
    }
    //printf("The vaule of %d is: %f",angel,b);
}

Strange: Write a C program to Check Strange number or Not

Check Strange number or Not 



#include<stdio.h>
int main()
{
    int a,b,n,j,temp=0;
    printf("Enter the number:");
    scanf("%d",&a);
    temp=a;
    while(temp>0)
    {
        j=temp%10;
        n=1;
        for(b=2;b<=j/2;b++)
        {
            if(j%b==0)
            {
                n=0;
                break;
            }
        }
        temp=temp/10;
    }
    if(n==1)
        printf("YES! %d is a Strange number ",a);
    else
    printf("No! %d is Not a strange number ",a);
}