0% found this document useful (0 votes)
73 views9 pages

Lab Manual Prog in C

The document contains 10 experiments for a lab manual on C programming: 1. Print a statement. 2. Write a program to add, subtract and find the average of two numbers. 3. Write a program to calculate E=m*C2. 4. Write a program to print a table of numbers. 5. Write a program to calculate simple interest. 6. Write a program to calculate compound interest. 7. Write a program to add two matrices. 8. Write a program to find the roots of a quadratic equation. 9. Write a program to find the largest of three numbers. 10. Write a program to print a pattern.

Uploaded by

harpreetchawla7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views9 pages

Lab Manual Prog in C

The document contains 10 experiments for a lab manual on C programming: 1. Print a statement. 2. Write a program to add, subtract and find the average of two numbers. 3. Write a program to calculate E=m*C2. 4. Write a program to print a table of numbers. 5. Write a program to calculate simple interest. 6. Write a program to calculate compound interest. 7. Write a program to add two matrices. 8. Write a program to find the roots of a quadratic equation. 9. Write a program to find the largest of three numbers. 10. Write a program to print a pattern.

Uploaded by

harpreetchawla7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Lab manual

Experiment No 1

Write a program in C to print “I am a student of ”.


//Program in C to print “I am a student of ”
# include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf(“I am a student of ”);
getch();
}
Experiment No 2

Write a program in C to add, subtract, and find average


of two numbers.
Algorithm
1. INPUT TWO NUMBERS
2. C=A+B // ADDITION OF TWO NUMBERS
3. D=A-B // SUBTRACTION OF TWO NUMBERS
4. E=C/2 // AVERAGE OF TWO NUMBERS
5. PRINT SUM OF TWO NUMBERS=C
6. PRINT SUBTRACTION OF TWO NUMBERS=D
7. PRINT AVERAGE OF TWO NUMBERS=E
8. STOP
Experiment No 3

Write a program in C to calculate E=m*C2.


ALGORITHM
1. INPUT M AND C
2. E=M*C*C
3. PRINT E
4. STOP

Experiment No 4

Write a program in C to print a Table.


ALGORITHM
1. INPUT THE NUMBER TO BE PRINTED X
2. FOR i =1 TO 10
3. PRINT X*i
4. STOP
Experiment No 5

Write a program in C to calculate the Simple Interest.


ALGORITHM
/P,R,T are Principal, rate of interest and Time.
1. INPUT P,R, T
2. Simple_Interest=(P*R*T)/100
3. Print Simple_Interest.
4. STOP

Experiment No 6

Write a program in C to calculate the Compound Interest.


ALGORITHM
/P,R,T are Principal, rate of interest and Time.
5. INPUT P,R,T

6. Compound Intrest =
7. Print Compound_Interest.
8. STOP
Experiment No 7

// A[N][N], B[N][N], C[N][N] are three square matrices


1. FOR I=1 TO N
2. FOR J=1 TO N
3. READ A[I][J]
4. FOR I=1 TO N
5. FOR J=1 TO N
6. READ B[I][J]
7. FOR I=1 TO N
8. FOR J=1 TO N
9. C[I][J] = A[I][J]+B[I][J]
10. FOR I=1 TO N
11. FOR J=1 TO N
12. PRINT B[I][J]
STOP
Experiment No 8

Write a program in C to find the roots of a quadratic


equation.
Algorithm
Roots_of_Quadratic_Equation
// a,b,c are the coefficient of ax2+bx+c=0
1. INPUT a,b,c
2. D=b2-4ac
3. IF D>=0
4. THEN X1= (- b + sqrt(D))/(2a);
5. X2= (- b - sqrt(D))/(2a);
6. ELSE PRINT “ROOTS ARE NOT REAL”
7. PRINT “ROOTS ARE” X1,X2
8. STOP
Experiment No 9

#include <stdio.h>
int main()
{
double n1, n2, n3;
printf("Enter three numbers: ");
scanf("%lf %lf %lf", &n1, &n2, &n3);
if( n1>=n2 && n1>=n3 )
printf("%.2f is the largest number.", n1);
if( n2>=n1 && n2>=n3 )
printf("%.2f is the largest number.", n2);
if( n3>=n1 && n3>=n2 )
printf("%.2f is the largest number.", n3);
return 0;
}

Experiment No 10
To print a pattern
Algorithm
FOR I = 1 TO N
FOR J=1 TO I
PRINT J
NEXT LINE
STOP

Experiment No 11
#include <stdio.h>
//#include<conio.h>
int main()
{
    int num;
    //clrscr();
printf("\n >> PROGRAM TO FIND FACTORIAL OF GIVEN NUMBER
using Function <<\n");
printf("\n Enter the Number whose Factorial you want: ");
scanf("%d",&num);
printf("\n The factorial of %d is %d.\n\n",num,factorial(num));
    //factorial(num) prints the value returned by the function
    //getch();
    return 0;
}
factorial(num1)
{
    int i,fact=1;
    for(i=num1; i>=2 ; i--)
  {
        fact = fact * i;
  }
    return fact; //returning fact to main function
}

You might also like