Академический Документы
Профессиональный Документы
Культура Документы
NO DATE EXPERIMENT NAME MSWORD Document creation, Text manipulation with scientific notation Table creation, table formatting and conversion Mail Merge and Letter preparation Drawing Flowchart MS EXCEL 5 6 7 8 Chart-Line, Bar and Pie Formula-Formula Editor Spread sheet- picture and graphics protecting the document and sheet Sorting and import/Export features C PROGRAMMING DATA TYPES EXPRESSION EVALUATION 9 10 11 12 13 14 15 16 17 Print Your Name Print Hello World Get The Single Value And Print The Value Get The Single Character And Print The Character Get The Multiple Character And Print The Characters Arithmetic Operation-addition ,subtraction, multiplication, division Arithmetic Operation-Switch Case Calculate the area of circle, square, Rectangle and triangle Swap Number Using Three Variables PAGE.NO SIGNATURE
1 2 3 4
INDEX 18 Swap Number Using Two Variables CONDITIONAL STATEMENTS 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 Greater Than 2 Number Greater Than 3 Number Odd Or Even Leap Year Or Not Positive Or Negative Sum of the even number and odd number Student Grade List LOOPING Print 10 Number Using For Loop Print Hello World 10 Times Using While Loop Print Hello World 10 Time Using Do While Loop Using Two For Loop Get The Number And Print The Number Armstrong Number Palindrome Number Reverse The Number Using Two For Loop Print The 10 Numbers Print 5 lines star Pascal triangle FUNCTION Without Parameter Without Return With Parameter Without Return Without Parameter With Return With Parameter With Return Call By Value Factorial Of A Given Number Function With Switch Case
ARRAY
43 44 45 46 47 48 49 50 51 52 53
Using One Dimensional Array Get 10 Number And Print 10 Number With For Loop Using One Dimensional Array Get Character And Print Character With For Loop Using Two Dimensional Array Get 10 Number And Print 10 Number With Two For Loop Matrix Addition Matrix Multiplication Matrix Inverse POINTER Using Address Change The I Value With J. Call By Reference STRUCTURE Print Student Details Fibonacci Series Factorial Program
EX.NO:09 DATE:
AIM: To write a c program to print your name. ALGORITHM: Step 1: Start the program. Step 2: Enter your name inside the printf statement [printf (your name)]. Step 3: stops the program.
OUTPUT www.nskinfo.com
AIM: To write a c program to print hello world. ALGORITHM: Step 1: Start the program. Step 2: Enter your name inside the printf statement [printf (hello world)]. Step 3: stops the program.
ALGORITHM: Step 1: Start the program. Step 2: Declare the variable-i[int i]. Step 3: Get the value form the user using scanf statement [scanf(%d,&i)]. Step 4: Print the value using printf statement [printf(%d,i)]. Step 5: stops the program.
clrscr(); int i; printf(enter the value=\n); scanf(%d,&i); printf(the value is=%d,i); getch(); }
ALGORITHM: Step 1: Start the program. Step 2: Declare the variable with single dimensional array.[char i[0]]. Step 2: Get the value form the user using scanf statement [scanf(%c,&i)]. Step3: Print the value using printf statement [printf(%c,i)]. Step 4: stops the program. Note: Charter will be stored in i variable according to size of the array.
PROGRAM #include<stdio.h> #include<conio.h> void main() { clrscr(); char i[0]; printf(enter the charater=\n);
AIM: To write a c program to print single character. ALGORITHM: Step 1: Start the program.
Step 2: Declare the variable with single dimensional array.[char i[10]]. Step 2: Get the value form the user using scanf statement [scanf(%s,&i)]. Step3: Print the value using printf statement [printf(%s,i)]. Step 4: stops the program. Note: Charter will be stored in i variable according to size of the array.
ALGORITHM: Step 1: Start the program. Step 2: Declare the variable i,j,add,sub,mul,div.n[int i,j,add,sub,mul,div,n]. Step 3: Create the menu using printf statement [printf(\n1.add\n2.sub\n3.mul\n4.div)] Step 4: Get the option value pass into switch statement[switch(n)]. Step 5: Using case statement print the answer according to option value. Step 6: stops the program.
printf(\n1.add\n2.sub\n3.mul\n.div); printf(enter your choic); scanf(%d,&n); switch(n) { case 1: Printf(enter the value of i & j=\n); Scanf(%d%d,&i,&j); add=i+j; printf(\nthe addition of two value is=%d,add); break; case 1: Printf(enter the value of i & j=\n); Scanf(%d%d,&i,&j); sub=i-j; printf(\nthe subtraction of two value is=%d,sub); break; case 1: Printf(enter the value of i & j=\n); Scanf(%d%d,&i,&j); mul=i*j; printf(\nthe multiplication of two value is=%d,mul); break; case 1: Printf(enter the value of i & j=\n); Scanf(%d%d,&i,&j); div=i%j; printf(\nthe division of two value is=%d,div); break; defult: printf(\ninvalid choice); } getch(); }
Enter the value of i &j=3 2 the addition of two value is=5 2 Enter the value of i &j=3 2 the subtraction of two value is=1 5 invalid choice
EX.NO:16 DATE:
ALGORITHM: Step 1: Start the program. Step 2: Declare the variable square,a,circle,pi,r,rect,w,p.tri,b,h[int square,a,circle,pi,r,rect,w,p.tri,b,h]. Step 3: Calculate the area of square,circle,rectangle,triangle. Step 4: Print the result. Step 5: stops the program.
int square,a,circle,pi=3.14,r,rect,w,b.tri,ba,h clrscr(); printf("Enter length of the square (a)=\n "); scanf(%d,&a); square=a*a; printf("Enter radius of the circle (r)=\n "); scanf(%d,&r); circle=pi*r*r; printf("Enter width(w) and breath(b) of the rectangle=\n "); scanf(%d%d,&w,&b); rect=w*b; printf("Enter base(ba) and heigth(h) of the triangle=\n "); scanf(%d%d,&ba,&h); tri=ba*h; printf(the area of square=%d\ncircle=%d\nrect=%d\ntri=%d\n,square,circle,rect,tri); getch(); }
OUTPUT Enter length of the square (a)=2 Enter radius of the circle (r)=2 Enter width (w) and breath(b) of the rectangle=2 3
Enter base (ba) and heigth(h) of the triangle=2 3 The area of square=4 Circle=12.56 Rectangle=6 Triangle=6
EX.NO:17 DATE:
ALGORITHM: Step 1: Start the program. Step 2: Declare the variable Step 3: swap the number using three variables. Step 4: Print the results. Step 5: Stops the program.
int i,j,temp; clrscr(); printf("Enter the i & j value=\n "); scanf("%d%d",&i&j); printf(before swap); Printf(\n%d\n%d\n,i,j); printf(after swap); temp=i; i=j; j=temp; Printf(\n%d\n%d\n,i,j); getch(); }
OUTPUT Enter the i & j value=3 4 before swap i=3; j=4; after swap i=4; j=3;
EX.NO:18 DATE:
AIM: To write a c program to swap number with three variable ALGORITHM: Step 1: Start the program.
Step 2: Declare the variable Step 3: swap the number using two variables. Step 4: Print the results. Step 5: stops the program.
clrscr(); printf("Enter the i & j value=\n "); scanf("%d%d",&i&j); printf(before swap); Printf(\n%d\n%d\n,i,j); printf(after swap); i=i+j; j=i-j; i=i-j; Printf(\n%d\n%d\n,i,j); getch(); }
OUTPUT Enter the i & j value=3 4 before swap i=3; j=4; after swap i=4; j=3;
AIM: To write a c program to calculate greater than two numbers. ALGORITHM: Step 1: Start the program. Step 2: get the three values.
Step 3: Compare the three value with if loop. Step 4: Print the results Step 5: stops the program.
PROGRAM #include< stdio.h> #include< conio.h> void main() { int m,n,p; clrscr(); printf("Enter m and n value= "); scanf("%d%d%d",&m,&n,&p); if(m>n && m>p)
printf("\n%d is greater,m); else if(n>m && n>p) printf("\n%d is greater,n); else printf("\n%d is greater,p); getch(); }
AIM: To write a c program to calculate odd or even. ALGORITHM: Step 1: Start the program. Step 2: Get two values. Step 3: divide the two value with if loop. Step 4: Print the results
PROGRAM #include< stdio.h> #include< conio.h> void main() { int n; clrscr(); printf("Enter A number : "); scanf("%d",&n); if(n%2 = 0)
EX.NO:22 DATE:
AIM: To write a c program to calculate leap year. ALGORITHM: Step 1: Start the program. Step 2: Get two values. Step 3: divide the two value with if loop. Step 4: Print the results Step 5: stops the program
PROGRAM #include< stdio.h> #include< conio.h> void main() { int y; clrscr(); printf("Enter the year(y)= "); scanf("%d",&y); if(y%4==0) printf("\n%d is leap year,m); else
EX.NO:23 DATE:
AIM: To write a c program to calculate positive or negative. ALGORITHM: Step 1: Start the program. Step 2: Get two values. Step 3: Compare the two value with if loop. Step 4: Print the results Step 5: stops the program
PROGRAM #include< stdio.h> #include< conio.h> void main() { int m,n; clrscr(); printf("Enter the value (m)= "); scanf("%d",&m); if(m>0) printf("\n%d is positive,m); else
EX.NO:24 DATE:
AIM: To write a c program to calculate sum of even number. ALGORITHM: Step 1: Start the program. Step 2: declare the variable i=1; Step 3: using while print the i value. Step 4: increment i value by 2.
Step 5: Calculate the sum value. Step 6: Print the sum value Step 7: stops the program.
PROGRAM #include<stdio.h> #include<conio.h> void main() { int i=2,n,sum=0; clrscr(); printf("\nEven numbers upto n number="); scanf("%d",&n); printf("The even numbers are"); while(i<n) { printf("\n%d",i); i+=2;
OUTPUT Even numbers upto n number=10 The even numbers are 1 3 5 7 9 The sum of even numbers are=25
EX.NO:24 DATE:
AIM: To write a c program to calculate sum of even number. ALGORITHM: Step 1: Start the program. Step 2: declare the variable i=1; Step 3: using while prints the i value. Step 4: increment i value by 2. Step 5: Calculate the sum value. Step 6: Print the sum value
PROGRAM #include<stdio.h> #include<conio.h> void main() { int i=1,n,sum=0; clrscr(); printf("\nodd numbers upto n number="); scanf("%d",&n); printf("The odd numbers are"); while(i<n) { printf("\n%d",i);
OUTPUT odd numbers upto n number=10 the odd numbers are 1 3 5 7 9 the sum of odd numbers are=25
EX.NO:26 DATE:
AIM: To write a c program to calculate palindrome number. ALGORITHM: Step 1: Start the program. Step 2: Declare the variable with i=1 Step 3: using for loop print 10 times. Step 4: stops the program.
PROGARM #include<stdio.h> #include<conio.h> void main() { int i; clrscr(); for(i=0;i<=10;i++) printf("%d\n",i); getch(); }
OUTPUT 1 2 3 4 5 6 7 8 9 10
EX.NO:27 DATE:
AIM: To write a c program to print 10 times using while loop ALGORITHM: Step 1: Start the program. Step 2: Declare the variable with i=1 Step 3: using while loop check the condition. Step 4: Print the result. Step 5: stops the program.
PROGARM #include<stdio.h> #include<conio.h> void main() { int i=1; clrscr(); while(i<=10) { printf("\nyou have learned a c program\n"); i++; } getch(); }
OUTPUT you have learned a c program you have learned a c program you have learned a c program you have learned a c program you have learned a c program you have learned a c program you have learned a c program you have learned a c program you have learned a c program you have learned a c program
EX.NO:28 DATE:
AIM: To write a c program to print 10 times using while loop. ALGORITHM: Step 1: Start the program. Step 2: Declare the variable with i=1 Step 3: print the condition with do keyword. Step 4: using while loop check the condition. Step 5: Print the result. Step 6: stops the program.
PROGARM #include<stdio.h> #include<conio.h> void main() { int i=1; clrscr(); do { printf("hello world\n"); while(i<10); i++; } getch(); }
OUTPUT hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world
EX.NO:29 DATE:
AIM: To write a c program for two for loop. ALGORITHM: Step 1: Start the program. Step 2: Use two for loop to print the value Step 3: stops the program.
PROGARM #include<stdio.h> #include<conio.h> void main() { int i,j,n; clrscr(); printf("the value of m and n is\n"); for(i=0;i<3;i++) for(j=0;j<3;j++) printf("%d,%d\n",m,n); getch(); }
OUTPUT the value of m and n is 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2
EX.NO:30 DATE:
AIM: To write a c program to calculate Armstrong number. ALGORITHM: Step 1: Start the program. Step 2: Get the value. Step 3: Find the reminder and multiply three times. Step 4: After 3 rd step find the quotient for that number. Step 5: After 4th step find the reminder. Step 6: After 5th step repeat 3 to 5 until reminder became zero. Step 7: Print the result.
PROGRAM #include<stdio.h> #include<conio.h> void main() { int n,sum=0,temp,rem,q; clrscr(); printf("Enter the no="); scanf("%d",&n); temp=n; while(n>0) { rem=n%10; sum=sum+rem*rem*rem; n=n/10; } if(sum==temp) { printf("\n%d is a Armstrong no",sum);
EX.NO:31&32 DATE:
AIM: To write a c program to calculate palindrome number. ALGORITHM: Step 1: Start the program. Step 2: Get the value Step 3: Find the reminder and multiply [0*10+reminder]/ Step 4: After 3 rd step find the quotient for that number. Step 5: After 4th step find the reminder. Step 6: After 5th step repeat 3 to 5 until reminder became zero. Step 7: Print the result. Step 8: stops the program.
PROGRAM #include<stdio.h> #include<conio.h> void main() { int num,temp,rem,sum=0; clrscr(); printf("\n\nEnter no: "); scanf("%d",&num); temp = num; while(num>0) { rem=num%10; //reminder num=num/10; //quotient sum=sum*10 + rem; //Builds value of reversed number } if (sum==temp) printf ("%d is a Palindrome no",sum); else printf ("%d is Not a Palindrome no",sum); getch (); }
EX.NO:34 DATE:
AIM: To write a c program for print 5 lines star ALGORITHM: Step 1: Start the program. Step 2: Use two for loop to print the star[for(i=0;i<5;i++),for(j=o;j<i;j++)] . Step 3: Stop the program
PROGRAM #include<stio.h> #include<conio.h> Void main() { int i,j clrscr(); for(i=0;i<5;i++) { for(j=o;j<i;j++) printf(*); } printf(\n); getch() }
OUTPUT * * * * * * * * * * * * * * *
EX.NO:35 DATE:
AIM: To write a c program for pascal triangle. ALGORITHM: Step 1: Start the program Step 2: Use three for loop to print triangle [for(i=1,j=n-i;i<=n;i++,j--).for(k=1;k<=j;k++), for(k=1;k<=l;k++)] Step 3: Stop the program
PROGRAM #include<stdio.h> #include<conio.h> void main() { int i,j,k,l,n; clrscr(); scanf("%d",&n); l=1; for(i=1,j=n-i;i<=n;i++,j--) { for(k=1;k<=j;k++) printf(" "); for(k=1;k<=l;k++) printf(" %d",i); printf("\n"); l+=2; } getch(); }
EX.NO:36 DATE:
AIM: To write a c program for function without parameter without return ALGORITHM: Step 1: Start the program. Step 2: In void main declare the function [function prototype-void add(). Step 3: After step2 calling the function [add ()]. Step 4: after step3 define the function [void add()] Step 5: stops the program.
PROGRAM #include<stdio.h> #include<conio.h> void main() { void add(); //function declaration or function prototype add(); //function calling } void add() //function definition or called function. { int i,j,k; clrscr(); printf("Enter the value of i & j="); scanf("%d%d",&i,&j); k=i+j; printf("\nThe addition of two number is=%d",k); getch(); }
OUTPUT Enter the value of i &j=2 3 The addition of two number is=5
EX.NO:37 DATE:
AIM: To write a c program for function with parameter without return ALGORITHM: Step 1: Start the program. Step 2:Declare the variable i,j inside the void main Step 2: In void main declare the function [function prototype-void add(int,int). Step 3: After step2 calling the function [add (i,j)]. Step 4: after step3 define the function [void add(int i,int j)] Step 5: Print the result. Step 6: stops the program.
PROGRAM #include<stdio.h> #include<conio.h> void add(int,int); void main() { int i,j; add(i,j); }
//function calling
void add(int i,int j) //function definition or called function. { int k; clrscr(); printf("Enter the value of i & j="); scanf("%d%d",&i,&j); k=i+j; printf("\nThe addition of two number is=%d",k); getch(); }
OUTPUT Enter the value of i &j=2 3 The addition of two number is=5
EX.NO:38 DATE:
AIM: To write a c program for function without parameter without return ALGORITHM: Step 1: Start the program. Step 2: In void main declare the function [function prototype-void add(). Step 3: After step2 calling the function [add ()]. Step 4: after step3 define the function [void add()] Step 5: Return the value. Step 6: Print the result in void main. Step 6: stops the program.
PROGRAM #include<stdio.h> #include<conio.h> int add(); //function declaration or function prototype void main() { int l; l=add(); //function calling printf("\nThe addition of two number is=%d",l); getch(); } int add() //function definition or called function. { int i,j,k; clrscr(); printf("Enter the value of i & j="); scanf("%d%d",&i,&j); k=i+j; return(k); }
OUTPUT Enter the value of i &j=2 3 The addition of two number is=5
EX.NO:39 DATE:
AIM: To write a c program for function without parameter without return ALGORITHM: Step 1: Start the program. Step 2: Declare the variable i,j inside the void main Step 3: In void main declare the function [function prototype-int add(int,int). Step 4: After step2 calling the function [add (i,j)]. Step 5: after step3 define the function [int add(int i,int j)] Step 6: Return the value. Step 7: Print the result in void main. Step 8: stops the program.
PROGRAM #include<stdio.h> #include<conio.h> int add(int,int,int); //function declaration or function prototype void main() { int i,j,k,l; l=add(i,j,k); //function calling printf("\nThe addition of two number is=%d",l); getch(); } int add(int i,int j,int k) { clrscr(); printf("Enter the value of i & j="); scanf("%d%d",&i,&j); k=i+j; return(k); } //function definition or called function.
OUTPUT Enter the value of i &j=2 3 The addition of two number is=5
EX.NO:40 DATE:
CALL BY VALUE
AIM: To write c programs for function call by value. ALGORITHM: Step 1: Start the program. Step 2: Declare the variable i,j inside the void main Step 2: before void main declare the function [function prototype-void change(int,int). Step 3: Print the result. Step 4: After step2 calling the function [change (i,j)]. Step 5: after step3 define the function [void change(int i,int j)] Step 6: Print the result. Step 7: stops the program.
PROGRAM #include<stdio.h> #include<conio.h> void change(int,int); void main() { int i=5,j=6; clrscr(); printf("before change"); printf("%d\n%d\n",i,j); change(i,j); printf("after change\n"); printf("%d\n%d\n",i,j); getch(); } void change(int i,int j) { clrscr(); i=8; j=9; } //function definition or called function. //function declaration or function prototype
//function calling
EX.NO:41 DATE:
AIM: To write a c program for factorial program ALGORITHM: Step 1: Start the program. Step 2: Enter the number. Step 3: It will send to the factorial function Step 4: In factorial function calculate the factorial of a given number[ k*fact(k-1)]. Step 5 Print the result.
PROGRAM #include <stdio.h> #include <conio.h> void main() { int n; clrscr(); printf("\n Enter a number :"); scanf("%d",&n); printf("\n Factorial value=%d",fact(n)); getch(); } int fact(int k) { if(k==0) return 1; else return k*fact(k-1); }
OUTPUT
EX.NO:43 DATE:
USING ONE DIMENSIONAL ARRAY GET 10 NUMBER AND PRINT 10 NUMBER WITH FOR LOOP
AIM: To write a c program for function calls by reference. ALGORITHM: Step 1: Start the program. Step 2: Declare the variable with one dimensional array. Step 3: use for loop get the value form the user. Step 4: use same for loop print them. Step 5: stops the program.
PROGRAM #include<stdio.h>
#include<conio.h> void main() { int a[20],i; clrscr(); printf("Enter the number 10 numbers=\n"); for(i=0;i<10;i++) scanf("%d\n",&a[i]); printf("the number is\n"); for(i=0;i<10;i++) printf("%d\n",a[i]); getch(); }
2 3 4 5 6 7 8 9 10 The number is 1 2 3 4 5 6 7 8 9 10
EX.NO:44 DATE:
USING ONE DIMENSIONAL ARRAY GET CHARACTER AND PRINTCHARACTER WITH FOR LOOP
AIM: To write a c program for using one dimensional array get character and print character
with for loop. ALGORITHM: Step 1: Start the program. Step 2: Declare the variable with one dimensional array. Step 3: Get the character with %c. Step 4: stops the program.
clrscr(); printf("enter the character="); scanf("%c",&a); printf("\nthe character is="); printf("%s",a); getch(); }
EX.NO:45 DATE:
USING ONE DIMENSIONAL ARRAY GET 10 NUMBER AND PRINT 10 NUMBER WITH FOR LOOP
ALGORITHM: Step 1: Start the program. Step 2: Declare the variable with one dimensional array. Step 3: use for loop get the value form the user. Step 4: use same for loop print them. Step 5: stops the program.
void main() { int a[10][10],i,j; clrscr(); printf("enter the numbers\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) scanf("%d",&a[i][j]); } printf("\nthe number is\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) printf("%d\t",a[i][j]); printf("\n"); } getch(); }
EX.NO:49 DATE:
AIM: To write a c program for function calls by reference. ALGORITHM: Step 1: Start the program. Step 2: Declare the variable i=5 and j with pointer. Step 3: Store the address of i into to the j. Step 4: change the j value without pointer variable. Step 5: Print i and j value Step 6: Store the address of i into to the j. Step 7: change the j value with pointer variable. Step 8: Print i and j value Step 9: stops the program.
void main() { int i=5,*j; clrscr(); j=&i; j=7; printf("before change\n"); printf("%d\n%d\n",i,j); j=&i; *j=7; printf("after change\n"); printf("%d\n%d\n",i,*j); getch(); }
EX.NO:50 DATE:
CALL BY REFERENCE
AIM: To write a c program for function calls by reference. ALGORITHM: Step 1: Start the program. Step 2: Declare the pointer variable *i,*j inside the void main Step 2: before void main declare the function [function prototype-void change(int*,int*). Step 3: Print the result in void main. Step 4: After step2 calling the function with address of i and j [change (&i,&j)]. Step 5: after step3 define the function [void change(int *i,int *j)] Step 6: Print the result in void main. Step 7: stops the program.
void change(int*,int*); void main() { int *i=5,*j=6; clrscr(); printf("before change"); printf("%d\n%d\n",i,j); change(&i,&j); printf("after change\n"); printf("%d\n%d\n",i,j); getch(); } void change(int *i,int *j) { clrscr(); *i=8; *j=9; }
//function calling
AIM: To write a c program to perform Matrix addition. ALGORITHM: Step 1: Start the program. Step 2: Read row and column of the matrix Step 3: Enter the elements of A matrix Step 4: Enter the elements of B matrix Step 5: print the A matrix in the matrix form Step 6: print the B matrix in the matrix form Step 7: Set a loop up to the row Step 8: Set a inner loop up to the column. Step 9: Add the elements of A and B in column wise and store the result in C matrix. Step 10: After the execution of the two loops. Print the value of C matrix. Step 11: stop.
void main() { int a[10][10],b[10][10],c[10][10]; int i,j,m,n;clrscr(); printf("Enter the rows and column of two matrices...\n"); scanf("%d%d",&m,&n); printf("Enter the elements of a A matrix.\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) scanf("%d",&a[i][j]); } printf("Enter the elements of a B matrix.\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) scanf("%d",&b[i][j]); } printf("\n The elements of A matrix"); for(i=0;i<m;i++) { printf("\n"); for(j=0;j<n;j++) printf("\t%d",a[i][j]); } printf("\n The elements of B matrix"); for(i=0;i<m;i++) { printf("\n");
for(j=0;j<n;j++) printf("\t%d",b[i][j]); } printf("\n The addition of two matrices"); for(i=0;i<m;i++) { printf("\n"); for(j=0;j<n;j++) { c[i][j]=a[i][j]+b[i][j]; printf("\t%d",c[i][j]); } } }
33 Enter the elements of a A matrix. 123456789 Enter the elements of a B matrix. 123456789 The elements of A matrix 1 4 7 1 4 7 2 8 14 2 5 8 2 5 8 4 10 16 3 6 9 3 6 9 6 12 18
AIM: To write a c program to perform Matrix Multiplication. ALGORITHM: Step 1: Start the program. Step 2: Read rows and columns limits for matrices m,n,p,q Step 3: Check p is equal to n else go to step 12. Step 4: Set a loop to get A matrix values. Step 5: Read matrix value a[i][j] Step 6: Set a loop to get B matrix values Step 7: Read matrix value b[i][j] Step 8: Repeat step 9 until i<m,j<n,k<p. Step 9: d[i][j]=0; d[i][j]=d[i][j]+a[i][k]*b[k][j] Step 10: Set a loop to print matrix values. Step 11: Print matrix value d[i][j] go to step 13. Step 12: Print the number of rows and columns should not be equal. Step13: Stop
{ int a[10][10],b[10][10],d[10][10]; int i,j,p,q,m,n,k;clrscr(); printf("Enter the size of the A matrix :"); scanf("%d%d",&p,&q); printf("Enter the size of the B matrix :"); scanf("%d%d",&m,&n); if(p==n) { printf("Enter the elements of a A matrix.\n"); for(i=0;i<p;i++) { for(j=0;j<q;j++) scanf("%d",&a[i][j]); } printf("Enter the elements of a B matrix.\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) scanf("%d",&b[i][j]); } for(i=0;i<m;i++) { for(j=0;j<n;j++) 41
} printf("Multiplication of A and B Matrix:\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) printf("%5d ",d[i][j]); printf("\n"); } } else printf("The no.of rows and columns should not be equal"); getch(); }
OUTPUT Enter the size of the A matrix :3 3 Enter the size of the B matrix :3 3 Enter the elements of a A matrix.
123456789 Enter the elements of a B matrix. 123456789 Multiplication of A and B Matrix: 30 36 42 66 81 96 102 126 150 42
ALGORITHM: Step 1: Start the program. Step 2: Initialize structure std with members. Step 3: Set up for loop to get student number, name and six subject marks. Step 4: Read s[i].sno,s[i].name,s[i].m1, s[i].m2, s[i].m3, s[i].m4, s[i].m5, s[i].m6. Step 5: s[i].tot= s[i].m1+ s[i].m2+ s[i].m3+ s[i].m4+ s[i].m5+ s[i].m6. Step 6: s[i].avg=s[i].tot/6 Step 7: Check if(s[i].avg>=75) S[i].grade=D Check if(s[i].avg<75 && s[i].avg>=60 S[i].grade=F Check if(s[i].avg<60 && s[i].avg>=50 S[i].grade=S Check if(s[i].avg<50 && s[i].avg>=35 S[i].grade=T Step 8: Set a loop to print student mark lists details. Step 9: print s[i].sno,s[i].name,s[i].total,s[i].avg,s[i].grade Step 10: stop.
char name[10],grade; float avg; } s[10]; void main() { float avg; int tot,n,i; clrscr(); printf("Enter the number of students to process"); scanf("%d",&n); printf(" enter student number,Name and 6 subjects mark..\n"); for(i=1;i<=n;i++) { scanf("%d%s%d%d%d%d%d%d",&s[i].sno,s[i].name,&s[i].m1,&s[i].m2 ,&s[i].m3,&s[i].m4,&s[i].m5,&s[i].m6); s[i].tot=s[i].m1+s[i].m2+s[i].m3+s[i].m4+s[i].m5+s[i].m6; s[i].avg=s[i].tot/6; if(s[i].avg>=75) s[i].grade='D'; else if(s[i].avg<75 && s[i].avg>=60) s[i].grade='F';
else if(s[i].avg<60 && s[i].avg>=50) s[i].grade='S'; else if(s[i].avg<50 && s[i].avg>=35) s[i].grade='T'; }
printf("Student mark list are..\n"); printf("S.NO\tSNAME\tTOTAL\tAVERAGE\tGRADE\n"); printf("-------------------------------------\n"); for(i=1;i<=n;i++) { printf("\n"); } } printf("%d\t%s\t%d\t%f\t%c",s[i].sno,s[i].name,s[i].tot, s[i].avg,s[i].grade);
OUTPUT Enter the number of students to process 4 enter student number,Name and 6 subjects mark.. 1 sathya 89 80 90 90 87 86 2 ani 79 78 78 89 77 75
3 kamal 55 56 50 56 59 60 4 anu 40 45 37 45 43 45 Student mark list are.. S.NO SNAME TOTAL AVERAGE GRADE -----------------------------------------------------------1 2 3 4 sathya ani kamal anu 522 476 336 255 87.000000 79.000000 56.000000 42.000000 D D S T
EX.NO:52 DATE:
Step 1: Start the program. Step 2: Enter the number. Step 3: Check whether the number is zero or not. If zero print Zero value. If not zero go further. Step 4: Set a loop up to the given number. Step 5: fib=fib+a; a=b; b=fib; Step 6: Every increment in the loop prints the value of fib. Step 7: After the execution of the loop stops the program.
printf ("Enter the number"); scanf ("%d", &num); printf ("\n FIBBNOCI SERIES\n"); if (num==0) printf ("0"); else { for (i=0;i<num;i++) { fib=fib+a; a=b; b=fib; printf ("%d\t", fib); } } }