6. Program for finding the factorial of a number
#include<stdio.h>
#include<conio.h> // Linux user - Remove this
int main() { // Variable for n=number and fact=factorial int n,fact=1; // Inputing number whose factorial is to be found printf("Enter number:"); scanf("%d",&n); // Calculating Factorial while(n>=1) { fact=fact*n; n--; } // Diaplaying Factorial printf("%d",fact); getch (); // Linux user - Remove this return 0; }
7. Program to find whether the entered character is vowel or not using if else
#include<stdio.h>#include<conio.h> // Linux user - Remove this int main() { // Declaring variable where c=character char c; // Inputing character printf("Enter character:"); scanf("%c",&c); // Determing whether entered character is vowel or not if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U') { printf("Entered character is vowel"); } else printf("Eneterd character is a constant"); getch(); // Linux user - Remove this return 0; }
8. Program to find whether the entered character is vowel or not using switch case
#include<stdio.h>#include<conio.h> // Linux user - Remove this int main() { // Declaring variable where c=character char c; // Inputing character printf("Enter character:"); scanf("%c",&c); // Determing whether entered character is vowel or not switch(c) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': printf("Character is vowel"); break; default: printf("Character is a constant"); } }
9. Program to print the table of a given number till the user wishes
#include<stdio.h>#include<conio.h> // Linux user - Remove this int main() { // Declaring Variable for n=number, tw=till where he wants to print the table int i, n, tw; // Inputting number and user wish printf("Enter the number whose table you want to generate:"); scanf("%d",&n); printf("Enter till where you want to generate table:"); scanf("%d",&tw); // Displaying table for(i=1;i<=tw;i++) { printf("%d * %d = %d \n",n,i,n*i); } getch(); // Linux user - Remove this return 0; }
#include<stdio.h>#include<conio.h> // Linux user - Remove this int main() { // Declaring variable for n=number, s=sum int n,s=0; do { // Inputting number printf("Enter any number:"); scanf("%d",&n); // Calculating sum until zero is not entered s=s+n; }while(n!=0); // Displaying sum of all integers entered printf("Sum of all integers=%d",s); getch(); // Linux user - Remove this return 0; }