Monday, April 29, 2013

Smallest multiple: What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

Write a program which is smallest positive number that is evenly divisible by all of the numbers from 1 to 20 in C




#include<stdio.h>
#include<conio.h>
int main()
{
int num=20,flag=0;

while(flag==0)
{
    if ((num%2)==0&&(num%3)==0&&(num%4)==0&&(num%5)==0&&(num%6)==0
    && (num%7)==0&&(num%8)==0&&(num%9)==0&&(num%10)==0&&(num%11)==0&&(num%12)==0
    && (num%13)==0&&(num%14)==0&&(num%15)==0&&(num%16)==0&&(num%17)==0&&(num%18)==0
    && (num%19)==0&&(num%20)==0)
    {
        flag=1;
        printf("%d",num);
    }
    num++;
}
}

Sunday, April 28, 2013

Convert digits/numbers into word in C

Write a program which will convert digits/numbers into word in C 





#include<stdio.h>
#include<conio.h>
#define MAX 10
int main(void)
{
int i,flag=0,number;
char arr0[10][6]={"","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
char arr1[10][8]={"","Ten","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninety"};
char arr2[10][10]={"","Eleven","Tewelv","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"};
int k[10]={0,0,0,0,0,0,0,0,0,0};
printf("Enter the number: ");
scanf("%d",&number);
printf("\nIn word the number is:");
printf("\n\t\n");
if (number==0)
    printf("Zero");
else
{
for(i=4;number>0;i--)
{
    k[i]=number%10;
    number/=10;
}
for(i=0;i<=4;i++)
  {
    if (k[i]>0||flag==1)
     {
    if (i==4)
        if(k[3]==1)
        printf("%s ",arr2[k[i]]);
        else
        printf("%s ",arr0[k[i]]);
    else if (i==3)
        if(k[3]==1 && k[4]>0)
        {
        }
        else
        printf("%s ",arr1[k[i]]);
    else if (i==2 && k[i]>0)
    printf("%s Hundred ",arr0[k[i]]);
    else if (i==1)
    {
        if (k[0]==1)
        {
        }
        else
        printf("%s ",arr0[k[i]]);
    printf("Thousand ");
    }
    else if (i==0)
    {
        if (k[0]==1 && k[1]>0)
        printf("%s ",arr2[k[1]]);
        else
        printf("%s ",arr1[k[i]]);
    flag=1;
    }
     }
  }
}
printf("\n\n");
return 0;
}

Saturday, April 27, 2013

Sum of all digits by using Function in C

Write a program to print sum of all digits by using function in C 

 

#include<stdio.h>
#include<conio.h>
int sum1(int n)
{
static int sum =0,s;
if(n!=0)
{
s=n%10;
sum=sum+s;
sum1(n/10);
}
return(sum);
}
int main()
{
int n,sum;
printf("Enter the numbers: ");
scanf("%d",&n);
sum =sum1(n);
printf("\n\n");
printf("Sum of digits is: %d",sum);
return 0;
}

ASCII: Find a ASCII value of a character in C

Write a program to find  a ASCII value of a character in C




#include<stdio.h>
#include<conio.h>
main()
{
int n;
char c;
printf("Enter any character: ");
scanf("%c",&c);
printf("\n the ascci value of character is:%d",c);
return 0;
}


String pettern in C

Write a program to print the following pattern
m
ma
man
mano
manos
manosh
manoshe
manosh
manos
mano
man
ma





#include<stdio.h>
main()
{
    int i,j;
    char string[]="manoshe\n";
    printf("\n\n");
    printf("manoshe\n");
    printf("____________\n");
    for(i=0;i<6;i++)
    {
        j=i+1;
        printf("| %-7.*s|\n",j,string);
    }
    for(i=6;i>=0;i--)
    {
        j=i+1;
        printf("| %-7.*s|\n",j,string);
    }
    printf("____________\n");
}

Pattern in C

Write a program to print the following pattern
1
12
123
1234
12345
1234
123
12




#include<stdio.h>
main()
{
    int i,j,n,k;
    printf("Enter the number:");
    scanf("%d",&n);
    for(i=1;i<n;i++)
    {
      for(k=1;k<=i;k++)
        printf("%d",k);
        printf("\n");
    }
    for(i=n;i>=0;i--)
    {
        for(k=1;k<=i;k++)
       printf("%d",k);
       printf("\n");
    }

}

Pattern:

Write a program to print:


#include<stdio.h>
#include<conio.h>
main()
{
    int a,b,c=70,d=70,e=1,i;
    char m;
    printf(" A B C D E F G H I J K L M\n");
    for(a=1;a<=6;a++)
    {
        for(m=65;m<=c;m++)
        printf(" %c",m);
        c--;
        {
            for(b=1;b<=e;b++)
            printf(" %c",32);
            e=e+(3-1);
        }
        for(m=d;m>=65;m--)
        printf(" %c",m);
        d--;
        printf("\n");
        printf("\n");
    }


}

Friday, April 26, 2013

Sum the series:Sum=(x2)1+(x2)2+(x2)3+.......+(x2)n

Write a C program to Calculate the below Series. The Value of x and n must take from input terminal.
Sum=(x2)1+( x2 )2+( x2 )3 + ….  +  (x2)n 




 #include<stdio.h>
main()
{
    int i,n,x,c,r=1,sum=0;
    printf("Enter the value of X:");
    scanf("%d",&x);
    printf("\nEnter the value of range for series:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        c=x*x;
        r*=c;
        sum+=r;
    }
    printf("\nThe sum is:");
    printf("%d\n",sum);
}

Pattern:1*5=5 2*5=10 3*5=15 4*5=20

Write a program to print          
           1*5=5
           2*5=10
           3*5=15
           4*5=20
           5*5=25 



#include<stdio.h>
main()
{
    int i=1,n,c=5;
    printf("\n\tEnter the range value:");
    scanf("%d",&n);
    printf("\nThe pattern is:\n");
        while(i<=n)
    {
       printf("%d * %d=%d\n",i,c,i*c);
       i++;
    }
}   

Pattern:1*1=1 2*2=4 3*3=9 4*4=16

Write a program to print
                        1*1=1      
                        2*2=4
                        3*3=9
                        4*4=16
                        5*5=25 



#include<stdio.h>
main()
{
    int i=1,n;
    printf("\n\tEnter the range value:");
    scanf("%d",&n);
    printf("\nThe pattern is:\n");
        while(i<=n)
    {
       printf("%d * %d=%d\n",i,i,i*i);
       i++;
    }
}

Pattern: 1 12 123 1234 12345

Write a program  to print 
                                          1
                                          12
                                          123
                                          1234
                                          12345 



#include<stdio.h>
main()
{
    int i,n,j;
    printf("\nEnter the range value:");
    scanf("%d",&n);
    printf("\nThe pattern is:\n");
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=i;j++)
        printf("%d",j);
        printf("\n");
    }
}

Array: Calculate average from a given array in C

Write a program in c which will calculate average of all values an array 



#include<stdio.h>
#include<conio.h>
main()
{
    int a[100],i,sum=0,average=0,n;
    printf("\n\tIT'S A PROGRAM TO CALCULATE AVERAGE FROM AN ARRAY\n");
    printf("\n\tEnter the array size: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
         printf("\nEnter the %d value: ",i);
        scanf("%d",&a[i]);
        sum+=a[i];
        average=sum/a[i];
    }
    printf("\n\tThe average is:");
        printf("%d\n",average);
}
 




Array: Sum of all values from an array in C

Write a program in c which will read and sum of all values an array 



#include<stdio.h>
#include<conio.h>
main()
{
    int a[100],i,n,sum=0;
    printf("\n\tIT'S A PROGRAM TO FRINT & SUM OF ALL VALUES AN ARRAY\n");
    printf("\n\tEnter the array size: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
         printf("\nEnter the %d value: ",i);
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    printf("\n\tThe sum is %d:\n",sum);
}

Array: Print odd numbers from a given array in C

Write a program in c which will  print odd numbers from a given array 

 
 

#include<stdio.h>
#include<conio.h>
main()
{
    int a[100],i,n;
    printf("\n\tIT'S A PROGRAM TO FIND ODD NUMBERS FROM A GIVEN ARRAY\n");
    printf("\n\tEnter the array size: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        printf("\nEnter the %d value: ",i);
        scanf("%d",&a[i]);
    }
    {
      printf("\n\tThe odd numbers are: ");
      for(i=1;i<=n;i++)
         if(a[i]%2!=0)
          {
              printf("%d ",a[i]);
          }

    }
}

Array: Print even number from a given array in C

Write a program in c which will  print even numbers from a given array 



#include<stdio.h>
#include<conio.h>
main()
{
    int a[100],i,n;
    printf("\n\tIT'S A PROGRAM TO FIND EVEN NUMBERS FROM A GIVEN ARRAY\n");
    printf("\n\tEnter the array size: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        printf("\nEnter the %d value: ",i);
        scanf("%d",&a[i]);
    }
    {
      printf("\n\tThe even numbers are: ");
      for(i=1;i<=n;i++)
         if(a[i]%2==0)
          {
              printf("%d ",a[i]);
          }

    }
}

Thursday, April 25, 2013

Function: Use of function

Write a program to show the use of function 


#include<stdio.h>
main()
{
int a,b,c;
printf("\n\tIT'S A PROGRAM  TO  SHOW THE USE OF FUNCTION\n");
printf("\nEnter the value of a:");
scanf("%d",&a);
printf("\nEnter the value of b:");
scanf("%d",&b);
c=rose(a,b);
printf("\nMultiplication of %d and %d is:",a,b);
printf("%d",c);
}

rose(x,y,p)
int p,x,y;
{
p =x*y;
return (p);
}

Riverse an integer number

Write a program in c which will reverse an integer number.After print the output make the sum of all digits. 



#include<stdio.h>
main()
{
int num, reverse, sum=0;
printf("\n\tIT'S A PROGRAM TO REVERSE AN INTEGER NUMBER\n");
printf("\n\nEnter the number for reverse:");
scanf("%d", &num);
printf("\nAfter Reverse the number is: ");
while(num!= 0)
{
  reverse= num%10;
  num /=10;
  sum += reverse;
  printf("%d", reverse);
}
printf("\n\nSum of all Digits: %d", sum);

getch();
return 0;
}

Perfect number:Perfect number in c

Write a program in c which will check a number perfect or not 



#include<conio.h>
#include<stdio.h>
main()
{
    int num,i=1,sum=0,j;
    printf("\n\tIT'S A PROGRAM TO CHACK A NUMBER PERFECT OR NOT");
    printf("\n\nEnter the number:");
    scanf("%d",&num);
    while(i<num)
    {
        for(j=1;j<=i;j++)
        if(num%i==0)
        sum=sum+i;
        i++;
    }
    if(sum==num)
    {
        printf("\n%d is a perfect number\n",num);
    }
    else
    {
        printf("\n%d is not a perfect number\n",num);
    }
    return 0;
}

Factorial in c

Write a program in c to find the factorial of a number 



#include<stdio.h>
#include<conio.h>
main()
{
    int i,sum=1,num;
    printf("\n\tIT'S A PROGRAM TO FIND THE FACTORIAL OF A NUMBER:");
    printf("\n\nEnter the number:");
    scanf("%d",&num);
    for(i=1;i<=num;i++)
    {
        sum*=i;

    }
    printf("\nFactorial value of %d is:",num);
    printf("%d\n",sum);
    }

Switch Programming: Switch programming in C

Write a program which will find the division from a average grade obtained by a student by using switch case in C 




#include<stdio.h>
#include<conio.h>
main()
{
    char ch;
    scanf("%c",&ch);
    switch (ch)
    {
        case 'A':
        printf("1st division");
        break;
        case 'B':
        printf("2nd division");
        break;
        case'C':
        printf("3rd division");
        break;
    }
    return 0;
}

Tuesday, April 23, 2013

Function: Check Palindrom number or Not by using function in C

Write a C program to  Check Palindrom number or Not by using function in C

#include<stdio.h>
#include<conio.h>
int rev_check(int n)
{
int rev,temp=0,a=10;
while(n>0)
{
rev=n%a;
n=n/a;
temp=temp*a+rev;
}
return(temp);
}
main()
{
int n;
printf("\nEnter the number: ");
scanf("%d",&n);
if(rev_check(n)==n)
printf("\nThe given number is a palindrome\n");
else
printf("\nthe given number is not a palindrome\n");
}

Function: Check Prime number or Not by using Function in C

Check Prime number or Not by using Function



#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    int prime(int x);
    int n,flag;
    printf("Enter the number: ");
    scanf("%d",&n);
    flag=prime(n);
    if(flag==1)
printf("\n Yes!! %d is Prime number \n",n);
    else
printf("\n No!! %d is not Prime number \n",n);
    }
int prime(int x)
{
       int i,a;
a=sqrt(x);
       if((x==1)||(x==2))
 return(0);
       else
       {
    for(i=2;i<=a;i++)
if(x%i==0)
   return(0);
    return(1);
}
}

Sum the Series: Sum=x1 + x1/2 + x1/3 + …. + x1/n

Write a C program to Calculate the below Series. The Value of x and n must take from input terminal.

Sum=x1 + x1/2 + x1/3  + ….  +  x1/n 



#include<stdio.h>
#include<conio.h>
main()
{
    int i,x,n,j;
    float sum=0.0,a=1.0,r,y;
    printf("Enter the value of X:");
    scanf("%d",&x);
    printf("\nEnter the range value for series:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        y=a/i;
        r=x*y;
        sum=sum+r;
    }
    printf("\nThe sum is:");
    printf("%f\n",sum);
}
 

Sum the Series: Sum = x + x2 + x3 +…. + xn

Write a C program to Calculate the below Series. The Value of x and n must take from input terminal.

  Sum = x + x2 + x3 +…. +  xn




#include<stdio.h>
main()
{
    int i,n,x,r=1,sum=0;
    printf("Enter the value of X:");
    scanf("%d",&x);
    printf("\nEnter the value of range for series:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        r=r*x;
        sum+=r;
    }
    printf("\nThe sum is:");
    printf("%d\n",sum);
}
 

Sum the series: sum= x+2x+3x+.......+xn

Write a C program to Calculate the below Series. The Value of x and n must take from input terminal.

Sum = x+2x+3x+.......+xn

 


#include<stdio.h>
main()
{
    int x,i,n,r,sum=0;
    printf("Enter the value of X:");
    scanf("%d",&x);
    printf("\nEnter the range value for series:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        r=i*x;
        sum+=r;
    }

   printf("\nThe sum is:);
    printf("%d\n",sum);
}
 

Find out the Multiple Number

Multiple Number




#include<stdio.h>
main()
{
int a, b;
printf("Enter the value of a and b:\n");
//while(scanf("%d %d", &a, &b)==2)
scanf("%d %d",&a,&b);
{
if(a%b==0||b%a==0)
{
printf("The given number is Multiple\n");
}
else
{
printf("The given number is not Multiple\n");
}
}
return 0;
}

Saturday, April 20, 2013

Matrix: Multiplication two Matrics

Multiplication two Matrices




#include<stdio.h>
#define MAX 10
void main()
{
    int a[MAX][MAX],b[MAX][MAX],c[MAX][MAX],i,j,n;
    printf("Enter the size of matrix: \n");
    scanf("%d",&n);
    printf("\nEnter the 1st matrix: \n");
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        scanf("%d",&a[i][j]);
    printf("\nEnter the 2nd matrix: \n");
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        scanf("%d",&b[i][j]);
    for(i=0;i<n;i++)
       for(j=0;j<n;j++)
            c[i][j]=a[i][j]*b[i][j];
   printf("\nThe Multiplication of two matrix is\n");
   for(i=0;i<n;i++)
   {
       printf("\n");
       for(j=0;j<n;j++)
            printf("%d\t",c[i][j]);
   }
   return 0;
}

Wednesday, April 17, 2013

Sum of first and last digit from given numbrs

Sum of first and last digit from  given numbers



#include<stdio.h>
int main()
{
int num,sum=0,i,lastDigit,temp=0;
printf("Enter any number: ");
scanf("%d",&num);
temp=num%10;
while(num!=0)
{
lastDigit=num;
num=num/10;
}
sum=temp+lastDigit;
printf("\nSum of first and last digit is:%d\n",sum);
}

Tuesday, April 16, 2013

Matrix: Addition two Matrics

Addition two Matrices 



#include<stdio.h>
#define MAX 10
void main()
{
    int a[MAX][MAX],b[MAX][MAX],c[MAX][MAX],i,j,n;
    printf("Enter the size of matrix: \n");
    scanf("%d",&n);
    printf("\nEnter the 1st matrix: \n");
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        scanf("%d",&a[i][j]);
    printf("\nEnter the 2nd matrix: \n");
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        scanf("%d",&b[i][j]);
    for(i=0;i<n;i++)
       for(j=0;j<n;j++)
            c[i][j]=a[i][j]+b[i][j];
   printf("\nThe Addition of two matrix is\n");
   for(i=0;i<n;i++)
   {
       printf("\n");
       for(j=0;j<n;j++)
            printf("%d\t",c[i][j]);
   }
   return 0;
}

Array: Find the second height value from a given array in C

Second Height Value from a Given Array 



#include<stdio.h>
int main()
{
    int i,n;
    int a[100];
    printf("Enter the size of array: \n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("Enter the %d value of array: \n",i+1);
        scanf("%d",&a[i]);
    }
    int max=a[0];
    int j=0;
    for(i=0;i<n;i++)
    {
        while(a[i]>max)
        {
            max=a[i];
            j=i;
        }
    }
    int semax=a[n-j-1];
    for(i=0;i<n;i++)
    {
        while(semax<a[i]&&j!=i)
            semax=a[i];
    }

    printf("Max value of array is:%d\n",max);
    printf("2nd Max value of array is:%d\n",semax);
}

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);
}

Sunday, April 14, 2013

String: Prints Initial Of Any Name

Write a C program which prints initial of any line 

#include<stdio.h>
#include<string.h>
int main()
 {
   char str[20];
   int i=0;
   printf("Enter a string: ");
   gets(str);
   printf("%c",*str);
   while(str[i]!='\0')
    {
       if(str[i]==' ')
      {
       i++;
       printf("%c",*(str+i));
      }
       i++;
   }
   return 0;
}

String: Write a c program to convert the string from lower case to upper case

Convert String from lowercase to uppercase 



#include<stdio.h>
#include<string.h>
int main()
{
  char str[50];
  int i,b=0;
  printf("Enter lowercase word: ");
  scanf("%s",str);
  b=strlen(str);
  for(i=0;i<=b;i++)
    {
        if(str[i]>=97&&str[i]<=122)
        str[i]=str[i]-32;
  }
  printf("\nThe string in Uppercase is:%s",str);
  return 0;
}

Array:Find the largest element/value form a given array using function

Find the largest element/value form a given array using function



#include<stdio.h>
#define MAX 100

int getMaxvalue();
int size;

int main()
{

    int a[MAX],max,i;
    printf("Enter the size of the array: \n");
    scanf("%d",&size);
    printf("Enter %d elements of an array: \n", size);
    for(i=0;i<size;i++)
    scanf("%d",&a[i]);
    max=getMaxvalue(a);
    printf("Largest element of an array is: %d",max);
    return 0;
}

int getMaxvalue(int a[])
{

    int i=1,max;

    max=a[0];

    while(i < size)
        {
      if(max<a[i])
           max=a[i];
      i++;
    }

    return max;
}

Pattern: Write a program to print the following output

                                   Pattern 
     Write a program to print the following output



#include<stdio.h>
main()
{
    int a=0,b,c=10,d=8,e,temp=0,res=0,i,j,n=8;


    for(b=1;b<=9;b++)
    {
        for(e=b;e<=b;e++)
        {
            temp=a*c+b;
            res=temp*d+e;
            printf("%d",temp);
            printf(" X %d + %d = %d\n",d,e,res);
            a=temp;
        }
    }
}


Saturday, April 13, 2013

String: Copy one string to another string without liberty function

Copy one string to another string without liberty function 



#include<stdio.h>
main()
{
    char string1[80],string2[80];
    int i;
    printf("Enter the line: ");
    printf("\t");
    //gets(string2);
    scanf("%s",string2);
    for(i=0;string2[i]!='\0';i++)
    string1[i]=string2[i];
    //string1[i]='\0';
    printf("\n\%s\n",string1);
    printf("\nNumber of charcter is: %d\n",i);
}

Decimal To Binary Conversion

Decimal To Binary Conversion in C 



#include<stdio.h>
int main()
{

    long int decimalNumber,remainder,quotient;
    int binaryNumber[100],i=1,j;
    printf("Enter any decimal number: ");
    scanf("%ld",&decimalNumber);
    quotient = decimalNumber;
    while(quotient!=0)
    {
         binaryNumber[i++]= quotient % 2;
         quotient = quotient / 2;
    }
    printf("\nEquivalent binary value of decimal number %d: ",decimalNumber);
    for(j=i-1;j>0;j--)
    printf("%d",binaryNumber[j]);
    printf("\n");
}

Pattern: 1 23 456 78910

Write a program to print 1
                                    23
                                    456
                                    78910




#include<stdio.h>
#include<conio.h>
int main()
{
    int a,b,c=1;
    for(a=1;a<=4;a++)
    {
        for(b=1;b<=a;b++)
        {
            printf("%d",c);
            c++;
        }
        printf("\n");
    }
}

Pattern: 1 22 333 4444 55555

Write a program to print 1 
                                                                           22
                                   333
                                   4444
                                   55555 



#include<stdio.h>
#include<conio.h>
void main()
{
    int a,b;
    for(a=1;a<=5;a++)
    {
        for(b=1;b<=a;b++)
        {
            printf("%d",a);
        }
        printf("\n");
    }
}

Srting Array: Write a programe to find vowels,consonants,words,letters,alphabet form a given string array

 Find vowels,consonants,words,letters,alphabet form a given string array 



#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
 char a[100];
 int b,d,e,i,l,p;
 b=d=e=0;
 printf("\nEnter the string : ");
 gets(a);
 l=strlen(a);
 for(i=0;a[i]!='\0';i++)
  {
   if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U')
   d++;
      if (a[i]==' ')
   e++;
   }
   p=l-(d+e);
   b=l-e;
   printf("\n\t No of vowels=%d \n",d);
   printf("\n\t No of consonants=%d \n ",p);
   printf("\n\t No of words=%d \n ",e+1);
   printf("\n\t No of total letters=%d \n",l);
   printf("\n\t No of alphabet=%d \n",b);
}

Serise Circuit: Sum of total registance of an Electric Circuit

Sum of total registance of an Electric Circuit
Ri=R1+R2+R3+............+R



#include<stdio.h>
#include<conio.h>
main()
{
    float sum=0.0,r;
    int i,j,n;
    printf("\t\tIts's a programe to find the total vale of serise circuit\n");
    printf("\n\nHow many registors you use in serise: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=1;j++)
        printf("\n\tEnter the valuse of %d registor:",i);
        scanf("%f",&r);
        sum+=r;
    }
    printf("\nThe total registance of the serise circuit is: %0.3f\n ",sum);
}

Power: Sum of total Power in Circuit.. P=P1+P2+P3+......+Pn

Power: Sum of total Power in Circuit.. P=P1+P2+P3+......+Pn
Where P=(I*I)R 



#include<stdio.h>
main()
{
    int i,n,j;
    float R,I,P=0.0,sum=0.0;
    printf("Enter the number which u want to use serise:\n");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=1;j++)
        printf("Enter the value of current:\n");
         scanf("%f",&I);
        printf("Enter the value of resestence:\n");
        scanf("%f",&R);
        P=(I*I)*R;
    }
    sum+=P;
    printf("The totel Power is:%f",sum);
}
 




Array: Dimentional Arry: Multiplication Table

Multiplication Table 



#include<stdio.h>
#include<conio.h>
#define ROWS 5
#define COLUMS 5
main()
{
    int row,colum,product[ROWS][COLUMS];
    int i,j;
    printf("Multiplication Table\n\n");
    printf(" ");
    for(j=1;j<=COLUMS;j++)
    printf("%4d",j);
    printf("\n");
    printf("   ----------------------\n");
    for(i=0;i<ROWS;i++)
    {
        row=i+1;
        printf("%2d |",row);
        for(j=1;j<=COLUMS;j++)
        {
            colum=j;
            product[i][j]=row*colum;
            printf("%4d",product[i][j]);
            //printf("----------------------\n");
        }
        printf("\n");
    }
}

String Array: Check palindrom word or Not from given String

Check palindrom word or Not from given String 



#include<stdio.h>
#include<conio.h>

#include<string.h>
int main()
{
char word[80], reverse_word[80];
int i, j, len;
scanf("%s", word);
len = strlen(word);
for(i = 0, j = len - 1; i < len; i++, j--)
{
reverse_word[i] = word[j];
}
reverse_word[i] = '\0';
printf("%s\n", reverse_word);
if (0 == strcmp(word, reverse_word))
{
printf("YES %s is a palindrome.\n", word);
}
else
{
printf("NO %s is not a palindrome.\n", word);
}
return 0;
}

Check Palindorm number or Not In c

Palindorm Number 



#include<stdio.h>
#include<conio.h>
main()
{
int n,rev=0,temp,a=10;
printf("Enter any number: ");
scanf("%d",&n);
temp=n;
while(temp!=0)
{
rev=rev*a;
rev=rev+temp%a;
temp=temp/a;
}
if(n==rev)
{
printf("%d is a palindrome number",n);
}
else
printf("%d is not a palindrome number",n);
return 0;
}

prime numbers between 1 to n in C program

prime numbers between 1 to n 





#include<stdio.h>


int main()
{

    int num,i,count,n;
    printf("Enter max range: ");
    scanf("%d",&n);

    for(num = 1;num<=n;num++)
{

         count = 0;

         for(i=2;i<=num/2;i++)
{
             if(num%i==0){
                 count++;
                 break;
             }
        }
        
         if(count==0 && num!= 1)
             printf("%d ",num);
    }
  
   return 0;
}