Monday, October 31, 2011

Sorting the String in Dictionary order

Given an Array of Strings Write a Program to Sort the String in Dictionary Order. Program: #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[25][25],t[25]; int i,j ,n; clrscr(); printf("enter the limit\n"); scanf("%d",&n); printf("enter the elements:\n"); for(i=0;i<n;i++) scanf("%s",&a[i]); for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { if(strcmp(a[i],a[j])>0) { strcpy(t,a[i]); strcpy(a[i],a[j]); strcpy(a[j],t); } } } printf("the...
Read full history - Sorting the String in Dictionary order

Sunday, October 30, 2011

String palindrome program in C (without string function )

Write a Program to find whether the Given String is Palindrome or not without using string functions. #include<stdio.h> #include<conio.h> void main() { char s1[20]; int i,j,len=0,flag=0; clrscr(); printf ("Enter a string:"); gets(s1);for(i=0;s1[i]!='\0';i++) len++; i=0; j=len-1; while(i<len) { if(s1[i]!=s1[j]) { flag=1; break; } i++; j--; } if(flag==0) printf("\nstring...
Read full history - String palindrome program in C (without string function )

Saturday, October 8, 2011

C program to find Compound Interest using functions

Write a program to display Compound Interest for a given principal amount for 1 yr. Use function to find the interest.... Program.. #include<stdio.h> #include<conio.h> float ci(int p,float r); void main() { int p; float r,i; clrscr(); printf("Enter...
Read full history - C program to find Compound Interest using functions

C program to check for Armstrong Number

Write a program in C to check whether the given number is Armstrong or not.... Program... #include<stdio.h> #include<conio.h> void main() { int num,r,sum=0,temp; clrscr(); printf("\nEnter a number:"); scanf("%d",&num); temp=num; while(num) { r=num%10; num=num/10; sum=sum+(r*r*r); } if(temp==sum) printf("\n%d...
Read full history - C program to check for Armstrong Number

C Program to check for Palindrome Number

Write a program to check whether the given number is palindrome or not.... Program #include<stdio.h> #include<conio.h> void main() { int num,r,sum=0,temp; clrscr(); printf("\nEnter a number:"); scanf("%d",&num); temp=num; while(num) { r=num%10; num=num/10; sum=(sum*10)+r; } if(temp==sum) printf("\n%d...
Read full history - C Program to check for Palindrome Number

Wednesday, October 5, 2011

Sum of a given series

Write a program to compute the sum of the following series: (1/1!)+(2/2!)+(3/3!)+..........................+(n/n!) Program... #include<stdio.h> #include<conio.h> float factorial(int n); void main() { int l,i; float sum=0.0; clrscr(); printf("Enter...
Read full history - Sum of a given series

Tuesday, October 4, 2011

Program to find the value of nCr

Write a program to find nCr.... Program: #include<stdio.h> #include<conio.h> long int factorial(int n); void main() { int n,r; long int ncr; clrscr(); l1:printf("Enter value of n and r to find the value of ncr(n>r)"); scanf("%d%d",&n,&r); if(n<r) { printf("Enter...
Read full history - Program to find the value of nCr

Finding Factorial of a number [ using Recursion & Iteration ]

 Write a program to find the factorial of a given number using recursion and iteration ..... Program: Using recursion... #include<stdio.h> #include<conio.h> long int recur_factorial(int n); void main() { int n; long int fact; clrscr(); printf("Enter...
Read full history - Finding Factorial of a number [ using Recursion & Iteration ]

Prime number [ using for, while, do-while ]

Write a program to display prime nos between 1 to 10 [ using for, while and do-while loop ] Program: Using for loop..... #include<stdio.h> #include<conio.h> void main() { int i,j,flag=0; clrscr(); printf("Prime no between 1 and 10 are:\n"); for(i=1;i<=10;i++) { for(j=1;j<=i;j++) { if(i%j==0) flag++; } if(flag==2) printf("%d\n",i); flag=0; } getch(); } Using...
Read full history - Prime number [ using for, while, do-while ]

Fibonacci series using Functions and Arrays

Write a program to display Fibonacci series by writing the value to the main().... [using function & arrays] Program: #include<stdio.h> #include<conio.h> long int fibo(int n); void main() { int l,i; long int fibonacci[50]; clrscr(); printf("Enter...
Read full history - Fibonacci series using Functions and Arrays

Pattern 1

Write a program to print the following pattern: (1,1)  (1,2)  (1,3) (3,1)  (3,2)  (3,3) (5,1)  (5,2)  (5,3) Program: #include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); for(i=1;i<6;i++) { for(j=1;j<4;j++) { if(i==2...
Read full history - Pattern 1

Monday, October 3, 2011

Arithmatic operation using Switch case

Write a program to perform addition, subtraction, multiplication, division by reading arithmetic operators using Switch case..... Program: #include<stdio.h> #include<conio.h> void main() { int a,b; char ch; clrscr(); printf("Enter two...
Read full history - Arithmatic operation using Switch case

About Me