Pages

Monday, January 9, 2012

C Programming to find nth term of Fibonacci series

/* to find nth term of Fibonacci's series */
#include<stdio.h>
#include<stdlib.h>
int fib(int);
int main()
{
    int n;
    printf("Enter the value of n: ");
    scanf("%d",&n);
    printf("%dth term of Fibonacci's series is %d\n",n,fib(n));
    system("pause");
    return 0;
}
int fib(int n)
{
  if (n < 2)
    return n;
  else
    return fib(n-1) + fib(n-2);
}

C Programming to find nth term of Fibonacci series

/* to find nth term of Fibonacci's series */
#include<stdio.h>
#include<stdlib.h>
int fib(int);
int main()
{
    int n;
    printf("Enter the value of n: ");
    scanf("%d",&n);
    printf("%dth term of Fibonacci's series is %d\n",n,fib(n));
    system("pause");
    return 0;
}
int fib(int n)
{
  if (n < 2)
    return n;
  else
    return fib(n-1) + fib(n-2);
}

Tuesday, January 3, 2012

C Programming to enter small letter return capital letter

/*Enter small letter return capital letter*/
#include<stdio.h>
#include<stdlib.h>
int cap(int);
int main()
{
    char i;
    printf("Enter character in small letter: ");
    scanf("%c",&i);
    i=(int)i;
    i-=32;
    printf("The character in capital letter:%c",i);
    printf("\n");
    system("pause");
    return 0;
}

C Programming to enter small letter return capital letter

/*Enter small letter return capital letter*/
#include<stdio.h>
#include<stdlib.h>
int cap(int);
int main()
{
    char i;
    printf("Enter character in small letter: ");
    scanf("%c",&i);
    i=(int)i;
    i-=32;
    printf("The character in capital letter:%c",i);
    printf("\n");
    system("pause");
    return 0;
}

Monday, January 2, 2012

C Programming to display ASCII code of all 256 characters

/*To display all ASCII codes */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int i;
    printf("ASCII CODE\tCharacter");
    for (i=1;i<=256;i++)
    {
        printf("\n%d\t\t%c",i,i);
        continue;
    }
    system("pause");
    return 0;
}

C Programming to display ASCII code of all 256 characters

/*To display all ASCII codes */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int i;
    printf("ASCII CODE\tCharacter");
    for (i=1;i<=256;i++)
    {
        printf("\n%d\t\t%c",i,i);
        continue;
    }
    system("pause");
    return 0;
}

C Programming to display ASCII values

/* to display ASCII values */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n;
    printf("Enter character: ");
    scanf("%c",&n);
    printf("The ASCII value of %c is %d",n,n);
    system("pause");
    return 0;
}

C Programming to display ASCII values

/* to display ASCII values */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n;
    printf("Enter character: ");
    scanf("%c",&n);
    printf("The ASCII value of %c is %d",n,n);
    system("pause");
    return 0;
}

C Programming of a infinite loop


/*infinite loop*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n=-5;
    while (n!=0)
    {
          printf("%d \t",n);
          n--;
    }
    system("pause");
    return 0;
}

C Programming to read a number and decide if its palandrome


/* to read a number and decide if its palandrome */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,rev=0,x,num;
    printf("Enter number: ");
    scanf("%d",&n);
    num=n;
    while(n!=0)
    {
        x=n%10;
        rev=rev*10+x;
        n/=10;
    }
    if (rev==num)
        printf("%d is palandrome",num);
    else
        printf("%d is not palandrome",num);
    system("pause");
    return 0;
}

C Programming to read a number and decide if its palandrome


/* to read a number and decide if its palandrome */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,rev=0,x,num;
    printf("Enter number: ");
    scanf("%d",&n);
    num=n;
    while(n!=0)
    {
        x=n%10;
        rev=rev*10+x;
        n/=10;
    }
    if (rev==num)
        printf("%d is palandrome",num);
    else
        printf("%d is not palandrome",num);
    system("pause");
    return 0;
}

C Programming of a infinite loop


/*infinite loop*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n=-5;
    while (n!=0)
    {
          printf("%d \t",n);
          n--;
    }
    system("pause");
    return 0;
}

C Programming to find factorial of a number using function


/* to find factorial of a number */
#include<stdio.h>
#include<stdlib.h>
long factorial(int);
int main()
{
    int n;
    printf("Enter the number: ");
    scanf("%d",&n);
    if (n<0)
        printf("Factorial of %d is not possible",n);
    else if (n==0)
        printf("Factorial of 0 is 1");
    else
        printf("Factorial of %d is %d",n,factorial(n));
    system("pause");
    return 0;
}
long factorial(int n)
{
    int i,fact=1;
    for(i=1;i<=n;i++)
    fact*=i;
    return fact;
}

C Programming to find factorial of a number 1 to 10


/* to find factorial of a number 1 to 10*/
#include<stdio.h>
#include<stdlib.h>
long factorial(int);
int main()
{
    int i;
    for (i=1;i<=10;i++)
        printf("\nFactorial of %d is %d",i,factorial(i));
    system("pause");
    return 0;
}
long factorial(int n)
{
    int i,fact=1;
    for(i=1;i<=n;i++)
    fact*=i;
    return fact;
}

C Programming to find factorial of a number 1 to 10


/* to find factorial of a number 1 to 10*/
#include<stdio.h>
#include<stdlib.h>
long factorial(int);
int main()
{
    int i;
    for (i=1;i<=10;i++)
        printf("\nFactorial of %d is %d",i,factorial(i));
    system("pause");
    return 0;
}
long factorial(int n)
{
    int i,fact=1;
    for(i=1;i<=n;i++)
    fact*=i;
    return fact;
}

C Programming to find factorial of a number using function


/* to find factorial of a number */
#include<stdio.h>
#include<stdlib.h>
long factorial(int);
int main()
{
    int n;
    printf("Enter the number: ");
    scanf("%d",&n);
    if (n<0)
        printf("Factorial of %d is not possible",n);
    else if (n==0)
        printf("Factorial of 0 is 1");
    else
        printf("Factorial of %d is %d",n,factorial(n));
    system("pause");
    return 0;
}
long factorial(int n)
{
    int i,fact=1;
    for(i=1;i<=n;i++)
    fact*=i;
    return fact;
}

Programming to read two numbers and display greater one


/* to read two nos and display greater one */
#include<stdio.h>
#include<stdlib.h>
int max(int,int);
int main()
{
    int a,b;
    printf("Enter two numbers: ");
    scanf("%d%d",&a,&b);
    printf("max=%d",max(a,b));
    system("pause");
    return 0;
}
int max(int a,int b)
{
    return (a>b?a:b);
}

Programming to read two numbers and display greater one


/* to read two nos and display greater one */
#include<stdio.h>
#include<stdlib.h>
int max(int,int);
int main()
{
    int a,b;
    printf("Enter two numbers: ");
    scanf("%d%d",&a,&b);
    printf("max=%d",max(a,b));
    system("pause");
    return 0;
}
int max(int a,int b)
{
    return (a>b?a:b);
}

C Programming to to read a number and count the no. of digits


/* to read a number and count the no. of digits */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n, count=0;
    printf("Enter number: ");
    scanf("%d",&n);
    while(n!=0)
    {
        n/=10;
        count+=1;
    }
    printf("The number of digits =%d",count);
    system("pause");
    return 0;
}

C Programming to to read a number and count the no. of digits


/* to read a number and count the no. of digits */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n, count=0;
    printf("Enter number: ");
    scanf("%d",&n);
    while(n!=0)
    {
        n/=10;
        count+=1;
    }
    printf("The number of digits =%d",count);
    system("pause");
    return 0;
}

C Programming to display 100 to 1


/*to display 100 to 1*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i;
    for (i=100; i>=1; i--)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to read a number and find its armstrong


/* to read a number and find its armstrong */
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    int n,x,sum=0,num;
    printf("Enter number: ");
    scanf("%d",&n);
    num=n;
    while(n!=0)
    {
        x=n%10;
        sum+=(float)pow(x,3);
        n/=10;
    }
    if (sum==num)
        printf("%d is armstrong",num);
    else
        printf("%d is not armstrong",num);
    system("pause");
    return 0;
}

C Programming to read a number and find its armstrong


/* to read a number and find its armstrong */
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    int n,x,sum=0,num;
    printf("Enter number: ");
    scanf("%d",&n);
    num=n;
    while(n!=0)
    {
        x=n%10;
        sum+=(float)pow(x,3);
        n/=10;
    }
    if (sum==num)
        printf("%d is armstrong",num);
    else
        printf("%d is not armstrong",num);
    system("pause");
    return 0;
}

C Programming to display 100 to 1


/*to display 100 to 1*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i;
    for (i=100; i>=1; i--)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to decide if a number is prime or composite


/*to decide prime or composite*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int n,i,flag=1;
    printf ("enter number: ");
    scanf ("%d",&n);
    for (i=2; i<=n/2; i++)
    {
        if (n%i==0)
        {
            flag=0;
        }
    }
    if (flag)
        printf ("%d is prime",n);
    else
        printf ("%d is composite",n);
       
    system ("pause");
    return 0;
}

C Programming to decide if a number is prime or composite


/*to decide prime or composite*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int n,i,flag=1;
    printf ("enter number: ");
    scanf ("%d",&n);
    for (i=2; i<=n/2; i++)
    {
        if (n%i==0)
        {
            flag=0;
        }
    }
    if (flag)
        printf ("%d is prime",n);
    else
        printf ("%d is composite",n);
       
    system ("pause");
    return 0;
}

C Programming to find factorial of a number


/*to find factorial*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n,fact=1;
    printf ("enter number: ");
    scanf ("%d",&n);
    if (n<0)
        printf ("factorial doesnot exist");
    else if (n==0)
        printf ("factorial of 0 is 1");
    else
    {
        for (i=n; i>=1; i--)
            fact*=i;
        printf ("factorial of %d is %d",n,fact);
    }
    system ("pause");
    return 0;
}

C Programming to display Fibonacci series


/*to display Fibonacci series*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int n,i,a=1,b=1,c;
    printf ("enter n: ");
    scanf ("%d",&n);
    printf ("%d\t%d\t",a,b);
    for (i=1; i<=n-2; i++)
    {
        c=a+b;
        printf ("%d\t",c);
        a=b;
        b=c;
    }
    system ("pause");
    return 0;
}

C Programming to display Fibonacci series


/*to display Fibonacci series*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int n,i,a=1,b=1,c;
    printf ("enter n: ");
    scanf ("%d",&n);
    printf ("%d\t%d\t",a,b);
    for (i=1; i<=n-2; i++)
    {
        c=a+b;
        printf ("%d\t",c);
        a=b;
        b=c;
    }
    system ("pause");
    return 0;
}

C Programming to find factorial of a number


/*to find factorial*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n,fact=1;
    printf ("enter number: ");
    scanf ("%d",&n);
    if (n<0)
        printf ("factorial doesnot exist");
    else if (n==0)
        printf ("factorial of 0 is 1");
    else
    {
        for (i=n; i>=1; i--)
            fact*=i;
        printf ("factorial of %d is %d",n,fact);
    }
    system ("pause");
    return 0;
}

C Programming to display multiplication table


/*to display the multiplication table*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n;
    printf ("enter number: ");
    scanf ("%d",&n);
    for (i=1; i<=10; i++)
        printf ("\n%dx%d=%d",n,i,n*i);
    system ("pause");
    return 0;
}

C Programming to display multiplication table using while loop


/*to display multiplication table using while loop*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n;
    printf ("enter number: ");
    scanf ("%d",&n);
    i=1;
    while (i<=10)
    {
        printf ("\n%dx%d=%d",n,i,n*i);
        i++;
    }
    system ("pause");
    return 0;
}

C Programming to display multiplication table using while loop


/*to display multiplication table using while loop*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n;
    printf ("enter number: ");
    scanf ("%d",&n);
    i=1;
    while (i<=10)
    {
        printf ("\n%dx%d=%d",n,i,n*i);
        i++;
    }
    system ("pause");
    return 0;
}

C Programming to display multiplication table


/*to display the multiplication table*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n;
    printf ("enter number: ");
    scanf ("%d",&n);
    for (i=1; i<=10; i++)
        printf ("\n%dx%d=%d",n,i,n*i);
    system ("pause");
    return 0;
}

C Programming to find sum of square of first n natural numbers


/*to find sum of square of first n odd natural numbers*/
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main( )
{
    int i,j=1,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
    {
        sum+=pow(j,2);
        j+=2;
    }
    printf ("sum=%d",sum);
    system ("pause");
    return 0;
}

C Programming to find sum of cube of first n natural numbers


/*to find sum of cube of first n even natural numbers*/
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main( )
{
    int i,j=2,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
    {
        sum+=pow(j,3);
        j+=2;
    }
    printf ("sum=%d",sum);
    system ("pause");
    return 0;
}

C Programming to find sum of cube of first n natural numbers


/*to find sum of cube of first n even natural numbers*/
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main( )
{
    int i,j=2,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
    {
        sum+=pow(j,3);
        j+=2;
    }
    printf ("sum=%d",sum);
    system ("pause");
    return 0;
}

C Programming to find sum of square of first n natural numbers


/*to find sum of square of first n odd natural numbers*/
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main( )
{
    int i,j=1,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
    {
        sum+=pow(j,2);
        j+=2;
    }
    printf ("sum=%d",sum);
    system ("pause");
    return 0;
}

C Programming to to find the sum of all numbers from 1 to 111 divisible by 3 but not by 2


/*to find the sum of all numbers from 1 to 111 divisible by 3 but not by 2*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,sum=0;
    for (i=1; i<=111; i++)
    {
        if (i%3==0&&i%2!=0)
        sum+=i;
    }
    printf ("sum=%d",sum);
    system ("pause");
    return 0;
}

C Programming to to find the sum of all numbers from 1 to 111 divisible by 3 but not by 2


/*to find the sum of all numbers from 1 to 111 divisible by 3 but not by 2*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,sum=0;
    for (i=1; i<=111; i++)
    {
        if (i%3==0&&i%2!=0)
        sum+=i;
    }
    printf ("sum=%d",sum);
    system ("pause");
    return 0;
}

C Programming to find sum of first n odd natural number


/*to find the sum of first n odd natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,j=1,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
    {
        sum+=j;
        j+=2;
    }
    printf ("\nsum of odd natural number=%d",sum);
    system ("pause");
    return 0;
}

C Programming to find sum of first n even natural numbers


/*to find the sum of first n even natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,j=2,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
    {
        sum+=j;
        j+=2;
    }
    printf ("\nsum of even natural number=%d",sum);
    system ("pause");
    return 0;
}

C Programming to find sum of first n even natural numbers


/*to find the sum of first n even natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,j=2,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
    {
        sum+=j;
        j+=2;
    }
    printf ("\nsum of even natural number=%d",sum);
    system ("pause");
    return 0;
}

C Programming to find sum of first n odd natural number


/*to find the sum of first n odd natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,j=1,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
    {
        sum+=j;
        j+=2;
    }
    printf ("\nsum of odd natural number=%d",sum);
    system ("pause");
    return 0;
}

C Programming to display first n natural number


/*to display first n natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to find sum of first n natural number


/*to find the sum of n natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
        sum+=i;
    printf ("\nsum=%d",sum);
    system ("pause");
    return 0;
}

C Programming to find sum of first n natural number


/*to find the sum of n natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n,sum=0;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
        sum+=i;
    printf ("\nsum=%d",sum);
    system ("pause");
    return 0;
}

C Programming to display first n natural number


/*to display first n natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i,n;
    printf ("enter n: ");
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to display all odd numbers from 1 to 100


/*to display odd numbers upto 100*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i;
    for (i=1; i<=100; i+=2)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to display all even numbers from 1 to 100


/*to display even numbers upto 100*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i;
    for (i=2; i<=100; i+=2)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to display all even numbers from 1 to 100


/*to display even numbers upto 100*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i;
    for (i=2; i<=100; i+=2)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to display all odd numbers from 1 to 100


/*to display odd numbers upto 100*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i;
    for (i=1; i<=100; i+=2)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to calculate total and % along with division


/*to calculate total and percentage along with division*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int s1,s2,s3,s4,s5,tot;
    float per;
    printf ("enter the marks of 5 subjects: ");
    scanf ("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
    tot=s1+s2+s3+s4+s5;
    per=tot/500.0*100;
    printf ("total=%d",tot);
    printf ("\npercentage=%f",per);
    if (s1>=40&&s2>=40&&s3>=40&&s4>=40&&s5>=40)
    {
        if (per>=80)
            printf ("\ndistinction");
        else if (per>=60)
            printf ("\nfirst division");
        else if (per>=45)
            printf ("\nsecond division");
        else
            printf ("\nthird division");
    }
    else
        printf ("\nfail");
    system ("pause");
    return 0;
}

C Programming to display all numbers from 1 to 100


/*to display 1 to 100*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i;
    for (i=1; i<=100; i++)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to display all numbers from 1 to 100


/*to display 1 to 100*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int i;
    for (i=1; i<=100; i++)
        printf ("%d\t",i);
    system ("pause");
    return 0;
}

C Programming to calculate total and % along with division


/*to calculate total and percentage along with division*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int s1,s2,s3,s4,s5,tot;
    float per;
    printf ("enter the marks of 5 subjects: ");
    scanf ("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
    tot=s1+s2+s3+s4+s5;
    per=tot/500.0*100;
    printf ("total=%d",tot);
    printf ("\npercentage=%f",per);
    if (s1>=40&&s2>=40&&s3>=40&&s4>=40&&s5>=40)
    {
        if (per>=80)
            printf ("\ndistinction");
        else if (per>=60)
            printf ("\nfirst division");
        else if (per>=45)
            printf ("\nsecond division");
        else
            printf ("\nthird division");
    }
    else
        printf ("\nfail");
    system ("pause");
    return 0;
}

C Programming to read four numbers and display greatest one


/*to read 4 numbers and display greatest one*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    float a,b,c,d;
    printf ("enter the numbers: ");
    scanf ("%f%f%f%f",&a,&b,&c,&d);
    if (a>b&&a>c&&a>d)
        printf ("%f is greatest",a);
    else if (b>c&&b>d)
        printf ("%f is greatest",b);
    else if (c>d)
        printf ("%f is greatest",c);
    else
        printf ("%f is greatest",d);
    system ("pause");
    return 0;
}

C Programming to read four numbers and display greatest one


/*to read 4 numbers and display greatest one*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    float a,b,c,d;
    printf ("enter the numbers: ");
    scanf ("%f%f%f%f",&a,&b,&c,&d);
    if (a>b&&a>c&&a>d)
        printf ("%f is greatest",a);
    else if (b>c&&b>d)
        printf ("%f is greatest",b);
    else if (c>d)
        printf ("%f is greatest",c);
    else
        printf ("%f is greatest",d);
    system ("pause");
    return 0;
}

C Programming to decide if a number is divisible by 2 but not by 3


/*to decide a number divisible by 2 but not by 3*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int n;
    printf ("enter number: ");
    scanf ("%d",&n);
    if (n%3==0&&n%2!=0)
       printf ("%d is divisible by 3 but not by 2",n);
    else
        printf ("condition doesnot meet");
    system ("pause");
    return 0;
}

C Programming to decide profit and loss along with amount


/*to decide profit or loss along with amount*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    float sp,cp,profit,loss;
    printf ("enter sp and cp: ");
    scanf ("%f%f",&sp,&cp);
    if (sp>cp)
    {
        profit=sp-cp;
        printf ("profit=%f",profit);
    }
    else
    {
        loss=cp-sp;
        printf ("loss=%f",loss);
    }
    system ("pause");
    return 0;
}

C Programming to read three numbers and display greater one


/*to read 3 numbers and display greatest one*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    float a,b,c;
    printf ("enter the numbers: ");
    scanf ("%f%f%f",&a,&b,&c);
    if (a>b&&a>c)
        printf ("%f is greatest",a);
    else if (b>c)
        printf ("%f is greatest",b);
    else
        printf ("%f is greatest",c);
    system ("pause");
    return 0;
}

C Programming to read three numbers and display greater one


/*to read 3 numbers and display greatest one*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    float a,b,c;
    printf ("enter the numbers: ");
    scanf ("%f%f%f",&a,&b,&c);
    if (a>b&&a>c)
        printf ("%f is greatest",a);
    else if (b>c)
        printf ("%f is greatest",b);
    else
        printf ("%f is greatest",c);
    system ("pause");
    return 0;
}

C Programming to decide profit and loss along with amount


/*to decide profit or loss along with amount*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    float sp,cp,profit,loss;
    printf ("enter sp and cp: ");
    scanf ("%f%f",&sp,&cp);
    if (sp>cp)
    {
        profit=sp-cp;
        printf ("profit=%f",profit);
    }
    else
    {
        loss=cp-sp;
        printf ("loss=%f",loss);
    }
    system ("pause");
    return 0;
}

C Programming to decide if a number is divisible by 2 but not by 3


/*to decide a number divisible by 2 but not by 3*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int n;
    printf ("enter number: ");
    scanf ("%d",&n);
    if (n%3==0&&n%2!=0)
       printf ("%d is divisible by 3 but not by 2",n);
    else
        printf ("condition doesnot meet");
    system ("pause");
    return 0;
}

C Programming to display the greater number


/*to display the greater number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    float a,b;
    printf ("enter two numbers: ");
    scanf ("%f%f",&a,&b);
    if (a>b)
       printf ("%f is greater than %f",a,b);
    else
        printf ("%f is greater than %f",b,a);
    system ("pause");
    return 0;
}

C Programming to display the greater number


/*to display the greater number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    float a,b;
    printf ("enter two numbers: ");
    scanf ("%f%f",&a,&b);
    if (a>b)
       printf ("%f is greater than %f",a,b);
    else
        printf ("%f is greater than %f",b,a);
    system ("pause");
    return 0;
}

C Programming to decide if the number is positive or negative


/*To decide if the number is positive, negative or 0*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int num;
    printf ("enter number: ");
    scanf ("%d",&num);
    if (num>0)
       printf ("%d is positive",num);
    else
        printf ("%d is negative or zero",num);
    system ("pause");
    return 0;
}

C Programming to decide if the number is odd or even


/*to decide odd or even*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int num;
    printf ("enter number: ");
    scanf ("%d",&num);
    if (num%2==0)
       printf ("%d is even",num);
    else
        printf ("%d is odd",num);
    system ("pause");
    return 0;
}

C Programming to decide if the number is odd or even


/*to decide odd or even*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int num;
    printf ("enter number: ");
    scanf ("%d",&num);
    if (num%2==0)
       printf ("%d is even",num);
    else
        printf ("%d is odd",num);
    system ("pause");
    return 0;
}

C Programming to decide if the number is positive or negative


/*To decide if the number is positive, negative or 0*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int num;
    printf ("enter number: ");
    scanf ("%d",&num);
    if (num>0)
       printf ("%d is positive",num);
    else
        printf ("%d is negative or zero",num);
    system ("pause");
    return 0;
}

C Programming to find if the number is positive


/*to find if the number is positive*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int num;
    printf ("enter number: ");
    scanf ("%d",&num);
    if (num>0)
       printf ("%d is positive",num);
    system ("pause");
    return 0;
}

C Programming to find if the number is positive


/*to find if the number is positive*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    int num;
    printf ("enter number: ");
    scanf ("%d",&num);
    if (num>0)
       printf ("%d is positive",num);
    system ("pause");
    return 0;
}