User:Fabianski Benz

 C-PROGRAMMING CODES FOR LEARNERS  
 * Code for finding out the factorial of a number

#include "

int main

{


 * int c, n, fact = 1;


 * printf("Enter a number to calculate it's factorial\n");


 * scanf("%d", &n);


 * for (c = 1; c <= n; c++)


 * fact = fact * c;


 * printf("Factorial of %d = %d\n", n, fact);


 * return 0;

}


 * Code for finding prime number

#include

main

{


 * int n, i = 3, count, c;


 * printf("Enter the number of prime numbers required\n");


 * scanf("%d",&n);


 * if ( n >= 1 )




 * printf("First %d prime numbers are :\n",n);


 * printf("2\n");


 * }


 * for ( count = 2 ; count <= n ; )




 * for ( c = 2 ; c <= i - 1 ; c++ )




 * if ( i%c == 0 )


 * break;


 * }


 * if ( c == i )




 * printf("%d\n",i);


 * count++;


 * }


 * i++;


 * }


 * return 0;


 * }

Code for checking whether a character is a vowel or a consonant

#include

#include

#include

int main

{


 * char ch;


 * clrscr;


 * printf("/n Enter Character : ");


 * scanf("%c",&ch);


 * if(ch=='a' || ch=='e' || ch=='o' || ch=='i'|| ch=='u' || ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')


 * printf("/n Given character is Vowel !");


 * else


 * printf("/n Given character is Consonant !");


 * getch;


 * return 0;

}