Neeraj Mishra

A crazy computer and programming lover. He spend most of his time in programming, blogging and helping other programming geeks.

C program to check given alphabate is vowel or not using switch case

#include<stdio.h> #include<conio.h> void main() { char ch; clrscr(); printf(“Enter an alphabate:”); scanf(“%c”,&ch); switch(ch) { case ‘a’: case ‘A’: case ‘e’: case ‘E’: case ‘i’: case ‘I’: case ‘o’: case ‘O’: case ‘u’: case ‘U’: printf(“The alphabate is vowel”); break; default: printf(“The alphabate is not vowel”); } getch(); }

C program to print size of different data types

#include<stdio.h> #include<conio.h> void main() { clrscr(); printf(“TypettttSize (bytes)”); printf(“nCharacterttt    %d”,sizeof(char)); printf(“nIntegertttt    %d”,sizeof(int)); printf(“nLong intttt    %d”,sizeof(long int)); printf(“nFloattttt    %d”,sizeof(float)); printf(“nDoubletttt    %d”,sizeof(double)); printf(“nLong doublettt    %d”,sizeof(long double)); getch(); }

C program to perform arithmetic operations using switch case

#include<stdio.h> #include<conio.h> #include<stdlib.h> void main() { int ch; float a,b,res; clrscr(); printf(“Enter two numbers:”); scanf(“%f%f”,&a,&b); printf(“nMenun1.Additionn2.Subtractionn3.Multiplicationn4.Division”); printf(“nEnter your choice:”); scanf(“%d”,&ch); switch(ch) { case 1: res=a+b; break; case 2: res=a-b; break; case 3: res=a*b; break; case 4: res=a/b; break; default: printf(“Wrong choice!!nPress any key…”); getch(); exit(0); } printf(“nResult=%f”,res); getch(); }

C program to swap two numbers using pointers

#include<stdio.h> #include<conio.h> void main() { int *a,*b,*temp; clrscr(); printf(“Enter two mumbers:”); scanf(“%d%d”,a,b); printf(“Before Swaping:na=%d b=%d”,*a,*b); temp=a; a=b; b=temp; printf(“nAfter Swaping:na=%d b=%d”,*a,*b); getch(); }

C program to read and display an array using pointer

#include<stdio.h> #include<conio.h> void main() { int a[50],*p,i,n; clrscr(); p=a; printf(“Enter size of array:”); scanf(“%d”,&n); printf(“Enter elements of array:”); for(i=0;i<n;++i) scanf(“%d”,p+i); for(i=0;i<n;++i) printf(“%d “,*(p+i)); getch(); }