#include
#include
main()
{
char x;
clrscr();
printf("Enter the charecter");
scanf("%c",&x);
if(x=='a'||'e'||'i'||'o'||'u')
printf("is vowel");
else
printf("is consonant");
getch();
}
switch case vowels and consonants by using OR operator
Switch case vowels and consonants by using OR operator
Switch Case Program to identify Vowels and Consonants in C
Switch Case Program to identify given character Vowels and Consonants in C
/* wap to determine whether the entered chracter is consonant or vowel*/
#include
main()
{
char ch;
clrscr();
printf("\n Enter any character:");
scanf("%c",&ch);
switch(tolower(ch))
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
printf("\n The character is vowel!");
break;
default :
printf("\n The chracter is consonant!");
}
getch();
}
Related Links :
C Program to accept arithmetic operator, accept two numbers and perform given operation
C Program to accept arithmetic operator, accept two numbers and perform given operation
#include
main()
{
char ch;
int num1,num2;
clrscr();
printf("\nEnter number ,another number and operator:");
fflush(stdin);
scanf("%d%d",&num1,&num2);
ch=getchar();
switch(ch)
{
case '+':
printf("\n addition of 2 numbers=%d",num1+num2);
break;
case '-':
printf("\n subtraction of 2 numbers=%d",num1-num2);
break;
case '/':
printf("\n division of 2 numbers=%d",num1/num2);
break;
case '*':
printf("\n multiplication of 2 numbers=%d",num1*num2);
break;
default:
printf("\n wrong choice!");
}
getch();
}
Related Links :
Two dimensional Array Transpose of Matrix In C, 2-D Array Dimensional, Multidimensional Array in C
Two dimensional Array Transpose of Matrix In C, 2-D Array Dimensional, Multidimensional Array in C
#include
#include
main()
{
int r[4][4],c[4][4],i,j,m,n;
clrscr();
printf("Enter the range of row=");
scanf("%d",&m);
printf("enter the range of columns=");
scanf("%d",&n);
for(i=0;i{
for(j=0;j{
scanf("%d",&r[i][j]);
}
}
printf("Matrix is=\n");
for(i=0;i{
for(j=0;j{
printf("%d\t",r[i][j]);
}
printf("\n");
}
printf("Transpose=\n");
for(i=0;i{
for(j=0;j{
printf("%d\t",r[j][i]);
}
printf("\n");
}
getch();
}
Related Links :
C Program (WAP) to show addition of two 2-dimensional Array
C Program (WAP) to show addition of two 2-dimensional Array
#include
#include
main()
{
int a[2][2],b[2][2],c[2][2],i,j;
clrscr();
printf("Enter the elements of matrix a=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Matrix is=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("Enter the elements of matrix b=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("Matrix is=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",b[i][j]);
}
printf("\n");
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf("Sum is=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
getch();
}
Related Links :
C Program to do Subtraction matrix by using 2D (2 Dimensional) Array
C Program to do Subtraction matrix by using 2D (2 Dimensional) Array
#include
#include
main()
{
int a[2][2],b[2][2],c[2][2],i,j;
clrscr();
printf("Enter the elements of matrix a=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("matrix is=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("Enter the elements of matrix b=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("Matrix is=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",b[i][j]);
}
printf("\n");
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j]-b[i][j];
}
}
printf("Substraction=\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
getch();
}
Related Links :
Find circumference of circle in C
Find circumference of circle in C
#include
#include
main()
{
float r,circumference;
clrscr();
printf ("enter value for r");
scanf("%f",&r);
circumference=2*3.14*r;
printf(" %f",circumference);
getch();
}
Related Links :
C Program to identify user entered number,Capital Letter, Small Letter or Symbol
C Program to identify user entered number,Capital Letter, Small Letter or Symbol
#include
#include
main()
{
char c;
clrscr();
printf (" enter any character");
scanf ("%c",&c);
if(c>=65 && c<=90)
printf (" capital letter");
else
{
if(c>=97 && c<=122)
printf (" small letter");
else
{
if(c>=48 && c<=57)
printf (" digit");
else
printf (" symbol");
}
}
getch();
}
Related Links :
Follow Anna
Dear Friends,
Thanks For Joining the My blog lernc.blogspot.com, well.... this Newsletter is mainly for My all Indian Friends Because the Revolution started By Anna Hajare is very Great opportunity for all of Indians to remove the corruption from INDIA, on this Occasion of Independence day we must decide thats we must follow Anna Hajare & give him full co-operation for his revolution.... No every Indian must be treat as ANNA & Must Join this revolution to make Indian free From Corruption ...
http://en.wikipedia.org/wiki/Anna_Hazare
भ्रष्टाचार के खिलाफ अन्ना हजारे की इस मुहीम से जुड़ने के लिए 022- 61550789 नंबर पर मिस्ड कॉल कर सकते हैं.
हजारे ने कहा, ‘मैं तब तक आमरण अनशन पर रहूंगा जब तक सरकार जन लोकपाल विधेयक का मसौदा बनाने वाली संयुक्त समिति में 50 प्रतिशत अधिकारियों के साथ बाकी स्थानों पर नागरिकों और विद्वानों को शामिल करने पर सहमत नहीं हो जाती.’ हजारे ने प्रधानमंत्री की अपील के बावजूद अपना अनशन शुरू किया. प्रधानमंत्री कार्यालय ने कल रात उनके फैसले पर निराशा जताई थी.
हम सब भारत वासियों को अन्ना हजारेजी को समर्थन देना है और ज्यादा से ज्यादा संख्या में नई दिल्ली पहुचना है.... या जहा है वहासे भी एकजुट होके अन्नाके के समर्थन में शांतिपूर्ण आन्दोलन करना चाहिए ... ताकि हम सब लोग इस भ्रष्टाचार से मुक्त हो सके और एक नए भारत का निर्माण कर सके. ... ध्यान रखिये ७४ सालके अन्ना हजारे आपके बच्चो के लिए ये सब कर रहे है ताकि उन्हें किसीको रिश्वत देनेकी नौबत न आये धन्यवाद् ... आपका दोस्त पंकज ...
Forward This mail To maximum Friends...
Thanks
From : lernc.blogspot.com (Glearn.Net Team)
Info Groups ( IGCT, India )
Related Links :
C Program to TO REVERSE THE GIVEN STRING using Pointers
C Program to TO REVERSE THE GIVEN STRING using Pointers
#include
#include
void strev(char *str1, char *str2);
void main()
{
char *str1, *str2;
clrscr();
printf("\n\n\t PLZ ENTER A STRING...: ");
gets(str1);
strev(str1,str2);
printf("\n\t YOUR THE REVERSED STRING IS...: ");
puts(str2);
getch();
}
void strev(char *str1, char *str2)
{
int i = 0, len = 0, r = 0;
while(*(str1+len)!='\0')
len++;
for(i=len-1; i>=0; i--)
{
*(str2+r) = *(str1+i);
r++;
}
*(str2+r) = '\0';
}
Related Links :
C Program to Printing on a printer Directly
#include
int main(void)
{
fprintf(stdprn, "It will Print on Printer Directly....");
fprintf(stdprn, "\n\rNo Out Put On Screen... ???\n\r");
fprintf(stdprn, "\n\rCheck it your self... :) \f");
return 0;
}
Related Links :
C Program to Identify, detect given string is palindrome or not
C Program to Identify, detect given string is palindrome or not
#include
#include
#define size 26
void main()
{
char strsrc[size];
char strtmp[size];
clrscr();
printf("\n Enter String:= "); gets(strsrc);
strcpy(strtmp,strsrc);
strrev(strtmp);
if(strcmp(strsrc,strtmp)==0)
printf("\n Entered string \"%s\" ispalindrome",strsrc);
else
printf("\n Entered string \"%s\" is not
palindrome",strsrc);
getch();
}
Related Links :
In C Or C++ How to find the memory leakage in the Program or project project
In C Or C++ How to find the memory leakage in the Program or project project
Well Friends i am providing a link of software which will help to find memory leakage in your project, Try it...
Well Friends i am providing a link of software which will help to find memory leakage in your project, Try it...
Related Links :
Sorting Text file Using C Program
Sorting Text file Using C Program
#include
#include
#include
const int MAX = 1024;
void insert_sorted (long *sorted, int count, long value)
{
int i = 0;
sorted[count] = value;
if (count == 0) return;
for (i = count;i >= 0; i--)
{
if (value < sorted[i-1])
sorted[i] = sorted[i-1];
else break;
}
sorted[i] = value;
}
int main (int argc, char *argv[])
{
FILE *infile = NULL;
long sorted[1024];
long value;
int count = 0;
int i = 0;
if (argc < 2) {
fprintf (stderr, "Usage : %s\n", argv[0]);
return 1;
}
infile = fopen (argv[1], "r");
if (NULL == infile) {
perror ("fopen");
return -1;
}
/* while file not ends */
while (!feof (infile)) {
fscanf (infile, "%ld\n", &value); /* fetch value */
insert_sorted (sorted, count, value); /* sort */
++count; /* increase number of sorted values */
}
/* display values */
printf ("Sorted values : ");
for (i = 0; i < count; i++ ) {
printf ("%ld ", sorted[i]);
}
/* cleanup */
if (infile) {
fclose (infile);
infile = NULL;
}
return 0;
}
Related Links :
memcpy Function Example in C
#include
#include
int main(void)
{
char array[1];
char *p;
p = (char *) malloc(sizeof(char)*20);
memcpy(p,"Life is Good",10);
memcpy(array,p,10);
printf("\n %s \n",array);
return 0;
}
Related Links :
C program to calculate length of given string & reverse string
C program to calculate length of given string & reverse string
#include
#include
#include
void main(){
int len;
char s[15];
clrscr();
printf("Enter a String : - ");
scanf("%s",s);
len=strlen(s);
printf("\n Length of String - %d ",len);
printf("\n Original String :- %s",s);
strrev(s);
printf("\n Reverse String :- %s",s);
getch();
}
Related Links :
C Program to calculate sum of array elements in C
C Program to calculate sum of array elements in C
#include
#include
void main(){
int array[5]={4,8,9,13,25};
int i,sum=0;
for(i=0;i<5;i++){
sum=sum+array[i];
}
printf("Sum of Array is %d ",sum);
getch();
}
Related Links :
C Program to reverse the given string
C Program to reverse the given string
#include
#include
main()
{
char str[50],revstr[50];
int i=0,j=0;
printf("Enter the string to be reversed : ");
scanf("%s",str);
for(i=strlen(str)-1;i>=0;i--)
{
revstr[j]=str[i];
j++;
}
revstr[j]='\0';
printf("Input String : %s",str);
printf("\nOutput String : %s",revstr);
getch();
}
Related Links :
C Program to sort the marks of students given in pre defined Array
C Program to sort the marks of students given in pre defined Array
#include
void sort(int m, int x[]);
main()
{
int i;
int marks[5]={40, 90, 73, 81, 35};
clrscr();
printf("Marks before sorting\n");
for(i=0; i<5; i++)
printf("%4d", marks[i]);
printf("\n\n");
sort(5,marks);
printf("Marks after sorting\n");
for(i=0; i<5; i++)
printf("%4d", marks[i]);
printf("\n");
getch();
}
void sort(int m, int x[])
{
int i, j, temp;
for(i=1; i<=m-1; i++)
{
for(j=1;j<=m-1;j++)
{
if(x[j-1]>=x[j]
{
temp=x[j-1];
x[j-1]=x[j];
x[j]=temp;
}
}
}
}
Related Links :
currency rate conversion Program by using pre-processor in C Language
currency rate conversion Program by using pre-processor in C Language
//file1.h
#define USD 1
//file2.h
#define UKP 1
//file3
#include
#include
#if (defined (USD))
#define currency_rate 46
#elif (defined (UKP))
#define currency_rate 100
#else
# define currency_rate 1
#endif
main()
{
int rs;
rs = 10 * currency_rate;
printf (“%d\n”, rs);
}
Related Links :
Pre Processing Calculation Example in C Language
Pre Processing Calculation Example in C Language
#define CUBE(x) x*x*x //A
#include
main ()
{
int k = 5;
int j = 0;
j = CUBE(k);
printf (“value of j is %d\n”, j);
}
Related Links :
Pre Processor Example in C
Pre Processor Example in C
#include
#define VAL 40; //A
#undef VAL //B
#define VAL 40 //C
main()
{
printf (“%d\n”, VAL); //D
}
Related Links :
Basic Pre-Processing Example In C
Pre-Processing Example In C
# include
#define VAL 35 // A
#define HELLO “HELLO”; // B
main ()
{
int res;
res = VAL-5; // C
printf (“res = VAL-5: res == %d\n”, res);
printf ( HELLO); //D
}
Related Links :
One Dimensional, two dimensional and 3-Dimensional Array Creation in C Language
One Dimensional, two dimensional and 3-Dimensional Array Creation in C Language
#include
main()
{
int a[2][3][4];
int b[3][4];
int c[4];
int cnt=0;
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
for(int k=0;k<4;k++)
{
a[i][j][k] = cnt;
cnt;
}
}
void print_onedim(int a[])
{
for(int i=0;i<4;i++)
printf("%d ",a[i]);
}
void print_twodim(int a[][4])
{
for(int j=0;j<3;j++)
print_onedim(a[j]);
printf("\n");
}
void print_threedim(int a[][3][4])
{
printf("Each two dimension matrix\n");
for(int j=0;j<2;j++)
print_twodim(a[j]);;
}
Related Links :
C Program to Prove Memory allocation for Integer is 2 byte by using array & Pointer
C Program to Prove Memory allocation for Integer is 2 byte by using array & Pointer
#include
void printarr(int a[]);
void printdetail(int a[]);
void print_usingptr_a(int a[]);
main()
{
int a[5];
int *b;
int *c;
for(int i = 0;i<5;i++)
{
a[i]=i;
}
printarr(a);
*b=2;
b++;
*b=4;
b++;
*b=6;
b++;
*b=8;
b++;
*b=10;
b++;
*b=12;
b++;
a=c; //error
printarr(a);
}
void printarr(int a[])
{
for(int i = 0;i<5;i++)
{
printf("value in array %d\n",a[i]);
}
}
void printdetail(int a[])
{
for(int i = 0;i<5;i++)
{
printf("value in array %d and address is %16lu\n",a[i],&a[i]);
}
}
void print_usingptr_a(int a[])
{
for(int i = 0;i<5;i++)
{
printf("value in array %d and address is %16lu\n",*a,a);
a++; // increase by 2 bytes
}
}
Related Links :
C Program to Print Value and address of an array elements
C Program to Print Value and address of an array elements
#include
void printarr(int a[]);
main()
{
int a[5];
for(int i = 0;i<5;i++)
{
a[i]=i;
}
printarr(a);
}
void printarr(int a[])
{
for(int i = 0;i<5;i++)
{
printf("value in array %d\n",a[i]);
}
}
void printdetail(int a[])
{
for(int i = 0;i<5;i++)
{
printf("value in array %d and address is %16lu\n",a[i],&a[i]);
}
}
Related Links :
C Program to show Working of an array
#include
main()
{
int a[5];
for(int i = 0;i<5;i++)
{
a[i]=i;
}
printarr(a);
}
void printarr(int a[])
{
for(int i=0;i<5;i++)
{
printf("value in array %d\n",a[i]);
}
}
Related Links :
C Program to show recursive function in c with stack overheads massage and memory address showing
C Program to show recursive function in c with stack overheads massage & memory address showing
#include
int fact(int n);
long old=0; \\E
long current=0; \\F
main()
{
int k = 4,i;
long diff;
i =fact(k);
printf("The value of i is %d\n",i);
diff = old-current;
printf("stack overheads are %16lu\n",diff);
}
int fact(int n)
{
int j;
static int m=0;
if(m==0) old =(long) &j;
if(m==1) current =(long) &j;
m++; \\C
printf("the address of j and m is %16lu %16lu\n",&j,&m);
if(n<=0)
return(1);
else
return(n*fact(n-1));
}
Related Links :
C Program to interchange the values of two different strings variable
C Program to interchange the values of two different strings variable
main ( )
{
char * s1 = “abcd”;
char s2[] = “efgh”;
printf( “%s %16lu \n, s1, s1);
printf( “%s %16lu \n, s2, s2);
s1 = s2;
printf( “%s %16lu \n, s1, s1);
printf( “%s %16lu \n, s2, s2);
}
Related Links :
C Program to Count the Number od Characters in given string by using /0
C Program to Count the Number of Characters in given string by using /0
main ( )
{
char s1[6] = “abcde ”;
int cnt = 0;
cnt = cnt_str(s1); \\ A
printf( “ total characters are %d \n”, cnt);
}
int cnt_str(char s1[]); \\ B
{
int cn = 0;
while ( (cn < 6) && s1[cn]! = ‘\0’)
cn++;
return(cn);
}
Related Links :
C Mark list Program using Structure
C Mark list Program using Structure
struct student
{
char name[30];
float marks;
} ;
main ( )
{
struct student *student1;
struct student student2;
char s1[30];
float f;
student1 = &student2;
scanf (“%s”, name);
scanf (“ %f”, & f);
*student1.name = s1;
student1-> name = f;
*student2.marks = f;
student1-> marks = s1;
printf (“ Name is %s \n”, *student1.name);
printf (“ Marks are %f \n”, *student2.marks);
}
Related Links :
C Multiple Structure Program of Mark-list
C Multiple Structure Program of Mark-list
struct student
{
name char[30];
marks float;
}
main ( )
{
struct student student1;
student1 = read_student ( )
print_student( student1);
read_student_p(student1);
print_student (student1);
}
struct student read_student( ) \\ A
{
struct student student2;
gets(student2.name);
scanf(“%d”,&student2.marks);
return (student2);
}
void print_student (struct student student2) \\ B
{
printf( “name is %s\n”, student2.name);
printf( “marks are%d\n”, student2.marks);
}
void read_student_p(struct student student2) \\ C
{
gets(student2.name);
scanf(“%d”,&student2.marks);
}
Related Links :
Subscribe to:
Posts (Atom)
If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE
More Useful Topics... |
|
History Of C..
In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
My 1st Program...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}
Next Step...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");
printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");
}