Posts

Prime Number with break

#include<stdio.h> void main() { int num,i,flag=0; printf("Enter The Number:"); scanf("%d",&num); for(i=2;i<=num/2;i++) { if(num%i==0) { flag=1; break; } } if(flag==0) printf("%d Number is Prime",num); else printf("%d Number is Not Prime",num); }

Escape Sequence in C

Image

Program to print Pyramid of stars:

Image
#include<stdio.h> void main() { int i,j; j=1; while(j<=6) { i=1;                 //******* while(i<=7)              //******* {                        //******* printf("*");             //******* i=i+1; } printf("\n"); j=j+1; } printf("\n Different Pyramid\n"); j=1; while(j<=6) { i=1; while(i<=j) { printf("*"); i=i+1; } printf("\n"); j=j+1; } printf("\n Different Pyramid\n"); j=6; while(j>=1) { i=1; while(i<=j) { printf("*"); i=i+1; } printf("\n"); j=j-1; } } Output:

Program to print table of given number

#include<stdio.h> void main() { int i=1,num; printf("\nenter the number:"); scanf("%d",&num); while(i<=10) {  printf("\n%d*%d=%d",num,i,i*num);  i=i+1; } }

Program to find whether a character is Alphabet, Digit or Special Character

#include<stdio.h> void main() { char ch; printf("\nEnter the Character:"); scanf("%c",&ch); if(ch>=65 && ch<=90 ||ch>=97 && ch<=122) printf("\nEntered character is Alphabet"); else if(ch>=48 && ch<=57) printf("\nEntered character %c is Digit",ch); else if(ch>=123 && ch<=127 ||ch>=91 && ch<=96 || ch>=32 && ch<=47|| ch>=58 && ch<=64) printf("\nEntered character %c is Special Character",ch); else printf("\nEntered character %c is Non Priantable Character",ch); }

program to find entered character is vowel or consonent with switch case

#include<stdio.h> #include<stdlib.h> void main() { char ch; printf("\nEnter any Character"); scanf("%c",&ch); switch(ch) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'a': case 'e': case 'i': case 'o': case 'u':printf("\nEntered character %c is vowel",ch); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0':printf("\nEntered character %c is a Digit",ch); break; default:printf("Entered character is not a vowel and digit"); } }

program to find character is vowel of digit

#include<stdio.h> #include<stdlib.h> void main() { char ch; printf("\nEnter any Character"); scanf("%c",&ch); if(ch=='A' || ch=='E'|| ch=='I'|| ch=='O'|| ch=='U'|| ch=='a'|| ch=='e'|| ch=='i'|| ch=='o'|| ch=='u') printf("\nEntered character %c is vowel",ch); else  if(ch=='1'|| ch=='2'|| ch=='3'|| ch=='4'|| ch=='5'|| ch=='6'|| ch=='7'|| ch=='8'|| ch=='9'|| ch=='0') printf("\nEntered character %c is a Digit",ch); else printf("Entered character is now a vowel and digit"); }