Sunday, July 21, 2013
Number Pattern-14
Number Pattern in C
#include<stdio.h>
int main()
{
int i,j;
printf("0\n");
for(i=9;i>=1;i--)
{
for(j=i;j<=9;j++)
printf("%d",j);
printf("0");
for(j=9;j>=i;j--)
printf("%d",j);
printf("\n");
}
return 0;
}
0 |
909 |
89098 |
7890987 |
678909876 |
56789098765 |
4567890987654 345678909876543 |
23456789098765400 |
1234567890987650000 |
#include<stdio.h>
int main()
{
int i,j;
printf("0\n");
for(i=9;i>=1;i--)
{
for(j=i;j<=9;j++)
printf("%d",j);
printf("0");
for(j=9;j>=i;j--)
printf("%d",j);
printf("\n");
}
return 0;
}
Matrix Multiplication
Multiplication of two matrix in C
Multiplication Matrix
#include<stdio.h>
#define M 20
int main()
{
int a[M][M],b[M][M],c[M][M],i,j,n;
printf("Enter the size of Matrix: ");
scanf("%d",&n);
printf("Enter the First matrix: ");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("\nEnter the Second matrix: ");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
printf("\nThe First matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",a[i][j]);
}
printf("\nThe Second matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",b[i][j]);
}
for(i=0;i<n;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]*b[i][j];
printf("\nThe Multiplication of two matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",c[i][j]);
}
return 0;
}
Multiplication Matrix
#include<stdio.h>
#define M 20
int main()
{
int a[M][M],b[M][M],c[M][M],i,j,n;
printf("Enter the size of Matrix: ");
scanf("%d",&n);
printf("Enter the First matrix: ");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("\nEnter the Second matrix: ");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
printf("\nThe First matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",a[i][j]);
}
printf("\nThe Second matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",b[i][j]);
}
for(i=0;i<n;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]*b[i][j];
printf("\nThe Multiplication of two matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",c[i][j]);
}
return 0;
}
Sum of two Matrix
Sum of two matrix in C
Addition of two matrix in C
#include<stdio.h>
#define M 20
int main()
{
int a[M][M],b[M][M],c[M][M],i,j,n;
printf("Enter the size of Matrix: ");
scanf("%d",&n);
printf("Enter the First matrix: ");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("\nEnter the Second matrix: ");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
printf("\nThe First matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",a[i][j]);
}
printf("\nThe Second matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",b[i][j]);
}
for(i=0;i<n;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
printf("\nThe Addition of two matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",c[i][j]);
}
return 0;
}
Addition of two matrix in C
#include<stdio.h>
#define M 20
int main()
{
int a[M][M],b[M][M],c[M][M],i,j,n;
printf("Enter the size of Matrix: ");
scanf("%d",&n);
printf("Enter the First matrix: ");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("\nEnter the Second matrix: ");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
printf("\nThe First matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",a[i][j]);
}
printf("\nThe Second matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",b[i][j]);
}
for(i=0;i<n;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
printf("\nThe Addition of two matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",c[i][j]);
}
return 0;
}
Armstrong Number upto N in C Program
Write
a c program for Armstrong number
#include<stdio.h>
main()
{
int num,r,sum,temp,min,max;
printf("Enter the minimum range: ");
scanf("%d",&min);
printf("\nEnter the maximum range: ");
scanf("%d",&max);
printf("\nArmstrong numbers in given range are: ");
printf("\n");
for(num=min;num<=max;num++)
{
temp=num;
sum = 0;
while(temp!=0)
{
r=temp%10;
temp=temp/10;
sum=sum+(r*r*r);
}
if(sum==num)
printf("%d ",num);
}
return 0;
}
C
program for Armstrong number
generation
How
to find Armstrong number in c
Code
for Armstrong number in c
#include<stdio.h>
main()
{
int num,r,sum,temp,min,max;
printf("Enter the minimum range: ");
scanf("%d",&min);
printf("\nEnter the maximum range: ");
scanf("%d",&max);
printf("\nArmstrong numbers in given range are: ");
printf("\n");
for(num=min;num<=max;num++)
{
temp=num;
sum = 0;
while(temp!=0)
{
r=temp%10;
temp=temp/10;
sum=sum+(r*r*r);
}
if(sum==num)
printf("%d ",num);
}
return 0;
}
Check Armstrong Number in C
Warp
to check a number is Armstrong
C program to check whether a number is Armstrong or not
Simple
c program for Armstrong number
Armstrong
number in c with output
#include<stdio.h>
int main(){
int num,r,sum=0,temp;
printf("Enter a
number: ");
scanf("%d",&num);
temp=num;
while(num!=0){
r=num%10;
num=num/10;
sum=sum+(r*r*r);
}
if(sum==temp)
printf("%d is an
Armstrong number",temp);
else
printf("%d is
not an Armstrong number",temp);
return 0;
}
Saturday, July 20, 2013
Fibonacci Series in C
Fibonacci Series in C Program
#include <stdio.h>
main()
{
int a=0, b=1,no,counter,c;
printf("PROGRAM TO FIND THE FIBONACCI SERIES UP TO N NO. IN SERIES");
printf("\n");
printf("\nENTER LENGTH OF SERIES (N) : ");
scanf("%d",&no);
printf("\nFIBONACCI SERIES");
printf("\n\t%d %d",a,b);
//LOOP WILL RUN FOR 2 TIME LESS IN SERIES AS THESE WAS PRINTED IN ADVANCE
for(counter = 1; counter <= no-2; counter++)
{
c=a + b;
printf(" %d",c);
a=b;
b=c;
}
printf("\n");
getch();
}
#include <stdio.h>
main()
{
int a=0, b=1,no,counter,c;
printf("PROGRAM TO FIND THE FIBONACCI SERIES UP TO N NO. IN SERIES");
printf("\n");
printf("\nENTER LENGTH OF SERIES (N) : ");
scanf("%d",&no);
printf("\nFIBONACCI SERIES");
printf("\n\t%d %d",a,b);
//LOOP WILL RUN FOR 2 TIME LESS IN SERIES AS THESE WAS PRINTED IN ADVANCE
for(counter = 1; counter <= no-2; counter++)
{
c=a + b;
printf(" %d",c);
a=b;
b=c;
}
printf("\n");
getch();
}
Palindrome Number in C
Palindrome Number in C Program
#include<stdio.h>
#include<conio.h>
main()
{
int n,rev=0,temp,a=10;
printf("Enter any number: ");
scanf("%d",&n);
temp=n;
while(temp!=0)
{
rev=rev*a;
rev=rev+temp%a;
temp=temp/a;
}
if(n==rev)
{
printf("%d is a palindrome number",n);
}
else
printf("%d is not a palindrome number",n);
return 0;
}
#include<stdio.h>
#include<conio.h>
main()
{
int n,rev=0,temp,a=10;
printf("Enter any number: ");
scanf("%d",&n);
temp=n;
while(temp!=0)
{
rev=rev*a;
rev=rev+temp%a;
temp=temp/a;
}
if(n==rev)
{
printf("%d is a palindrome number",n);
}
else
printf("%d is not a palindrome number",n);
return 0;
}
Convert Km to Meter in C Program
Convert Km to Meter, Centimeter or Millimeter
#include<stdio.h>
int main()
{
float km,ans;
char v;
printf("Enter K.M. : ");
scanf("%f",&km);
printf("KM will be changed in (M,s,m) : ");
fflush(stdin);
scanf("%c",&v);
if(v=='M')
ans=km*1000;
if(v=='s')
ans=km*100000;
if(v=='m')
ans=km*1000000;
printf("Answer : %.2f",ans);
return 0;
}
#include<stdio.h>
int main()
{
float km,ans;
char v;
printf("Enter K.M. : ");
scanf("%f",&km);
printf("KM will be changed in (M,s,m) : ");
fflush(stdin);
scanf("%c",&v);
if(v=='M')
ans=km*1000;
if(v=='s')
ans=km*100000;
if(v=='m')
ans=km*1000000;
printf("Answer : %.2f",ans);
return 0;
}
Calculate Simple Interest in C Program
Calculate Simple Interest in C Program
#include<stdio.h>
int main()
{
float pa,ir,ti,interest;
printf("Type your principle amount : ");
scanf("%f",&pa);
printf("\n Type your rate of intrest : ");
scanf("%f",&ir);
printf("\n Type time (in year) : ");
scanf("%f",&ti);
interest=p*ir*t/100;
printf("\n You will get interest : %.2f",interest);
return 0;
}
#include<stdio.h>
int main()
{
float pa,ir,ti,interest;
printf("Type your principle amount : ");
scanf("%f",&pa);
printf("\n Type your rate of intrest : ");
scanf("%f",&ir);
printf("\n Type time (in year) : ");
scanf("%f",&ti);
interest=p*ir*t/100;
printf("\n You will get interest : %.2f",interest);
return 0;
}
Friday, July 19, 2013
Pattern-15
Pattern-15 Pattern in C |
1 2 3 4 5 6 7 8 9 10 |
36 37 38 39 40 41 42 43 44 11 |
35 64 65 66 67 68 69 70 45 12 |
34 63 84 85 86 87 88 71 46 13 |
33 62 83 96 97 98 89 72 47 14 |
32 61 82 95 100 99 90 73 48 15 |
31 60 81 94 93 92 91 74 49 16 |
30 59 80 79 78 77 76 75 50 17 |
29 58 57 56 55 54 53 52 51 18 |
28 27 26 25 24 23 22 21 20 19 |
#include<stdio.h>
int main()
{
int a[10][10],i,j,low=0,top=9,n=1;
for(i=0;i<5;i++,low++,top--)
{
for(j=low;j<=top;j++,n++)
a[i][j]=n;
for(j=low+1;j<=top;j++,n++)
a[j][top]=n;
for(j=top-1;j>=low;j--,n++)
a[top][j]=n;
for(j=top-1;j>low;j--,n++)
a[j][low]=n;
}
for(i=0;i<10;i++)
{
printf("\n\n\t");
for(j=0;j<10;j++)
{
printf("%5d",a[i][j]);
}
}
printf("\n\n");
return 0;
} - See more at: http://www.programming-and-it-research-center.blogspot.com/search/label/Pattern#sthash.On2pnzIc.dpuf
int main()
{
int a[10][10],i,j,low=0,top=9,n=1;
for(i=0;i<5;i++,low++,top--)
{
for(j=low;j<=top;j++,n++)
a[i][j]=n;
for(j=low+1;j<=top;j++,n++)
a[j][top]=n;
for(j=top-1;j>=low;j--,n++)
a[top][j]=n;
for(j=top-1;j>low;j--,n++)
a[j][low]=n;
}
for(i=0;i<10;i++)
{
printf("\n\n\t");
for(j=0;j<10;j++)
{
printf("%5d",a[i][j]);
}
}
printf("\n\n");
return 0;
} - See more at: http://www.programming-and-it-research-center.blogspot.com/search/label/Pattern#sthash.On2pnzIc.dpuf
#include<stdio.h>
int main()
{
int a[10][10]={0},i,j,low=0,top=9,n=1;
for(i=0;i<5;i++,low++,top--)
{
for(j=low;j<=top;j++,n++)
a[i][j]=n;
for(j=low+1;j<=top;j++,n++)
a[j][top]=n;
for(j=top-1;j>=low;j--,n++)
a[top][j]=n;
for(j=top-1;j>low;j--,n++)
a[j][low]=n;
}
printf("\t\t\t\tPerfect Square\n");
for(i=0;i<10;i++)
{
printf("\n\n\t");
for(j=0;j<10;j++)
{
printf("%6d",a[i][j]);
delay(300);
}
}
return 0;
}
#include<stdio.h>
int main()
{
int a[10][10],i,j,low=0,top=9,n=1;
for(i=0;i<5;i++,low++,top--)
{
for(j=low;j<=top;j++,n++)
a[i][j]=n;
for(j=low+1;j<=top;j++,n++)
a[j][top]=n;
for(j=top-1;j>=low;j--,n++)
a[top][j]=n;
for(j=top-1;j>low;j--,n++)
a[j][low]=n;
}
for(i=0;i<10;i++)
{
printf("\n\n\t");
for(j=0;j<10;j++)
{
printf("%5d",a[i][j]);
}
}
printf("\n\n");
return 0;
} - See more at: http://www.programming-and-it-research-center.blogspot.com/search/label/Pattern#sthash.On2pnzIc.dpuf
int main()
{
int a[10][10],i,j,low=0,top=9,n=1;
for(i=0;i<5;i++,low++,top--)
{
for(j=low;j<=top;j++,n++)
a[i][j]=n;
for(j=low+1;j<=top;j++,n++)
a[j][top]=n;
for(j=top-1;j>=low;j--,n++)
a[top][j]=n;
for(j=top-1;j>low;j--,n++)
a[j][low]=n;
}
for(i=0;i<10;i++)
{
printf("\n\n\t");
for(j=0;j<10;j++)
{
printf("%5d",a[i][j]);
}
}
printf("\n\n");
return 0;
} - See more at: http://www.programming-and-it-research-center.blogspot.com/search/label/Pattern#sthash.On2pnzIc.dpuf
#include<stdio.h>
int main()
{
int a[10][10],i,j,low=0,top=9,n=1;
for(i=0;i<5;i++,low++,top--)
{
for(j=low;j<=top;j++,n++)
a[i][j]=n;
for(j=low+1;j<=top;j++,n++)
a[j][top]=n;
for(j=top-1;j>=low;j--,n++)
a[top][j]=n;
for(j=top-1;j>low;j--,n++)
a[j][low]=n;
}
for(i=0;i<10;i++)
{
printf("\n\n\t");
for(j=0;j<10;j++)
{
printf("%5d",a[i][j]);
}
}
printf("\n\n");
return 0;
} - See more at: http://www.programming-and-it-research-center.blogspot.com/search/label/Pattern#sthash.On2pnzIc.dpuf
int main()
{
int a[10][10],i,j,low=0,top=9,n=1;
for(i=0;i<5;i++,low++,top--)
{
for(j=low;j<=top;j++,n++)
a[i][j]=n;
for(j=low+1;j<=top;j++,n++)
a[j][top]=n;
for(j=top-1;j>=low;j--,n++)
a[top][j]=n;
for(j=top-1;j>low;j--,n++)
a[j][low]=n;
}
for(i=0;i<10;i++)
{
printf("\n\n\t");
for(j=0;j<10;j++)
{
printf("%5d",a[i][j]);
}
}
printf("\n\n");
return 0;
} - See more at: http://www.programming-and-it-research-center.blogspot.com/search/label/Pattern#sthash.On2pnzIc.dpuf
Subscribe to:
Posts (Atom)