Posts

Showing posts from February, 2012

Program for Matrix Addition

#include<iostream.h> #include<conio.h> void main() { int a[3][3],b[3][3],c[3][3],i,j; clrscr(); cout<<"Enter the Elements of the Ist Matrix"; for(i=0;i<3;i++) for(j=0;j<3;j++) cin>>a[i][j]; cout<<"Enter the Elements of the IInd Matrix"; for(i=0;i<3;i++) for(j=0;j<3;j++) cin>>b[i][j]; //Sum starts here for(i=0;i<3;i++) for(j=0;j<3;j++) c[i][j]=a[i][j]+b[i][j]; cout<<"\nThe addition of input   Matrix is\n"; for(i=0;i<3;i++) { cout<<"\n"; for(j=0;j<3;j++) cout<<"\t"<<c[i][j]; } cout<<"\nPress any key to continue..."; getch(); } Output Enter the Elements of the Ist Matrix 1               2               3 4               5               6 7               8               9 Enter the Elements of the IInd Matrix 9               8               7 6               5         

Program for Junior class students in QBASIC

Program- 1 Cls Print   "Program for addition of two numbers"; Print   "Enter first number:" INPUT   a Print   "Enter second number:" INPUT   b c = a + b Print   "The addition of given numbers is :", c Program -2 Cls Print   "Program for bigger in two numbers"; Print   "Enter first number:" INPUT   a Print   "Enter second number:" INPUT   b If (a > b) Then Print   "First number is greater" Else Print   "Second number is greater" Program -3 Cls Print   "Program for printing your name 5 times using for loop"; For i = 0 To 4 Print   "Ankit" Next   i Program -4 Cls Print   "Program for printing first ten natural numbers using while loop: "; i = 1 While (i <=10) Print   i I=i+1 Wend

Program for Greater number in three numbers using function

#include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("enter the numbers"); scanf("%d   %d %d",&a,&b,&c); greater(a,b,c); getch(); } greater( a,b,c) int a,b,c; { if(a>b) { if(a>c) { printf("first number is greater") ; } else { printf("third number is greater"); } } else { if(b>c) { printf("second number is greater"); } else { printf("third number is greater"); } } } Output enter the numbers6 7 8 third number is greater

program for printing fibonacci series

#include<stdio.h> #include<conio.h> void main() { int a=0,b=1,c=1,e=1,n; printf("enter the number"); scanf("%d",&n); do { printf("%d\n",b); b=a+e; a=e; e=b; c=c+1; }while(n>=c); getch(); }   Output enter the number 4 1 1 2 3

program for printing pyramid

#include<stdio.h> #include<conio.h> void main() {         int i,j,k,n;         clrscr();         printf("enter the number=");         scanf("%d",&n);         for(i=1;i<=n;i++)         {         for(j=i;j<=n-1;j++)         {         printf(" ");         }         for(k=1;k<=i;k++)         {         printf("*");         }         for(k=2;k<=i;k++)         {         printf("*");         }         printf("\n");         }         getch();         }                                                                               Output enter the number=6          *        ***      *****    *******   ********* ***********