You are on page 1of 61

Name: Chauhan Vinit Rameshbhai

Enrollment number: 21BT01006


Subject: Computer Programming (CP-1)
Subject Code: BTCS104
Batch: A
Division: 2021-22
Dept/ Branch/ Program: B.Tech Chemical
School: School of Technology

|Page
RECORD OF
WORK DONE
Date of Signature
Sheet Experiment Name Remarks
No. Experiment by Teacher

1. Loci of points and engineering curve.

2. Projection of planes and line.

3. Orthographic projection with


sectional views.

4. Projection and sections of solids.

5. Development of surfaces.

6. Isometric views.

|Page
RECORD OF WORK DONE

|Page
CERTIFICATE

This is to certify that the work entered in this laboratory journal is the work of

Ms./Mr. JAIN SWAYAM ASHISHBHAIof SCHOOL OF TECHONOLOGY.

B.TECH No.and has satisfactorily


Discipline, Enrollment 21BT01017
(CHEMICAL)
|Page
completed the required number of experiments for the 2nd Semester, Academic Year 2021– 22 in the
Engineering
Date: : 6 /8/22 Signature:

RECORD OF WORK DONE


Date of Signature
Sheet Experiment Name Remarks
No. Experiment by Teacher

1. Loci of points and engineering curve.

2. Projection of planes and line.

3. Orthographic projection with


sectional views.

4. Projection and sections of solids.

5. Development of surfaces.

6. Isometric views.

|Page
RECORD OF WORK DONE
Date of Signature
Sheet Experiment Name Remarks
No. Experiment by Teacher

1. Loci of points and engineering curve.

2. Projection of planes and line.

3. Orthographic projection with


sectional views.

4. Projection and sections of solids.

5. Development of surfaces.

6. Isometric views.

|Page
RECORD OF WORK DONE
Date of Signature
Sheet Experiment Name Remarks
No. Experiment by Teacher

1. Loci of points and engineering curve.

2. Projection of planes and line.

3. Orthographic projection with


sectional views.

4. Projection and sections of solids.

5. Development of surfaces.

6. Isometric views.

|Page
RECORD OF WORK DONE

Date of Signature
Sheet Experiment Name Remarks
No. Experiment by Teacher

1. Loci of points and engineering curve.

2. Projection of planes and line.

3. Orthographic projection with


sectional views.

4. Projection and sections of solids.

5. Development of surfaces.

6. Isometric views.

|Page
CERTIFICATE

This is to certify that the work entered in this laboratory journal is the work of

1st Year Chemical.,


Mr. KANSARA KRISH SHAILESH o

Discipline, EnromentB.TECH
No.and has satisfactorily 21BT01021

completed the required number of experiments for the 2nd Semester, Academic Year 2021– 22 in the
Engineering

Engineering Physics Laboratory as laid down by the University.

Date: 6/8/22 Signature:


Place: Vadodara Seal:

|Page
CERTIFICATE

This is to certify that the work entered in this laboratory journal is the work of

1st Year Chemical.,


Mr. PADHIYAR HITESHSINH PRUTHVIRAJSINHof
Of SHOOL OF TECHNOLOGY. ,

B.TECH
Of SCHOOL OF TECHNOLOGY Discipline, Enrollment No.and has satisfactorily 21BT01030

completed the required number of experiments for the 2nd Semester, Academic Year 2021– 22 in the
Engineering
Engineering Physics Laboratory as laid down by the University.

Date: 6/8/22 Signature:


Place: Vadodara Seal:

|Page
CERTIFICATE
B.TECH 21BT01030

This is to certify that the work entered in this laboratory journal is the work of

1st Year Chemical.,


Ms./Mr. CHAUHAN VINIT RAMESHBHAI of

B.TECH 21BT01006
Discipline, Enroment No. and has satisfactorily
Signature:
Place: Vadodara
completed the required number of experiments for theSeal:
2nd Semester, Academic Year 2021– 22 in the
Engineering

Engineering Physics Laboratory as laid down by the University.

Date: 6/8/22 Signature:

Place: Vadodara Seal:

|Page
CERTIFICATE

This is to certify that the work entered in this laboratory journal is the work of

1st Year Chemical.,


Ms./Mr. CHAUHAN VINIT RAMESHBHAI of

Discipline, Enroment No. and has satisfactorily

completed the required number of experiments for the 2nd Semester, Academic Year 2021– 22 in the
Engineering

Engineering Physics Laboratory as laid down by the University.

Date: 6/8/22 Signature:


Place: Vadodara Seal:

|Page
Practical:1

|Page
|Page
Practical:2

AIM: “C program for adding two numbers”.

DESCRIPTION/THEORY:
 The general form of call scanf() function is
Scanf(const char*characters_set);
 The function scanf() is used to read formatted input from std in C language.
 It returns the whole number of characters written in it otherwise, returns a negative
value.
 Int: As the name suggests that an int variable is used to store an integer

PROGRAM:
#include<stdio.h>
Int main()
{
int num1,num2,sum;
printf(“enter the value of num1”);
scanf(“%d”,& num1);
printf(“enter the value of num2”);
scanf(“%d”,& num2);
sum=num1+num2;
printf(“sum=%d”, sum);
return 0;
}

OUTPUT:
enter the value of num1: 9
enter the value of num2: 10
sum=19

|Page
|Page
Practical:3

AIM: Program to find the area and circumference of circle.

DESCRIPTION/THEORY:
 The input has been taken from user using scanf().
 Int: As the name suggests that an int variable is used to store an integer.
 float: It is used to store decimal numbers(numbers with floating point value) with
single precision.
 Now we will apply the formula of area and circumference of a circle.

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
Int r;
float a,c;
printf(“enter value of radius”);
scanf(“%d”,&r);
a=3.14*r*r;
c=2*3.14*r;
printf(“value of a is%f”,a);
printf(“value of c is%f”,c);
return 0;
}

OUTPUT:
enter the value of radius: 67
value of a is:14095.45996
value of c is :420.760010

|Page
|Page
Practical:4

AIM: Program to find Simple Interest.

DESCRIPTION/THEORY:
 float: It is used to store decimal numbers(numbers with floating point values)with
single precision.
 We will ask from the user to use scanf.
 Now putting the value of principal amount, rate of interest and time period using the
formula of simple interest.
 Now print the result using printf().

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
float p,r,t,si;
p=20;
r=30;
t=50;
si=p*r*t/100;
printf(“enter the si=%f”,si);
scanf(“%f”,&si);
return 0;
}

OUTPUT:
enter the si=300.000000

|Page
|Page
Practical:5

AIM: Program to convert degree Centigrade to Fahrenheit.

DESCRIPTION/THEORY:
 We will ask the user to enter the temperature in degree Celsius with the help of
scanf().
 Now, using the formula for converting to Fahrenheit we will print the result using
printf().

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
float f, c;
printf(“enter the degree centigrate”);
scanf(“%f”,&c);
f=(c*9/5)+32;
printf(“degree fahernheit=%f”,f);
return 0;
}

OUTPUT:
enter the degree centigrade: 45
degree fahernheit=113.000000

|Page
|Page
Practical:6

AIM: Program to calculate sum of 5 variable and print average.

DESCRIPTION/THEORY:
 We will ask the user to enter any random five numbers by using scanf(). Then we will
display the sum of that numbers using printf().
 Now we will apply average formula and display the result by using printf().

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
Int a, b, c, d, e, f;
Printf(“enter the 5numbers”);
Scanf(“%d%d%d%d%d,&a,&b,&c,&d,&e”);
f=a+b+c+d+e/5;
printf(“average=%d”,f);
scanf(“avg=%d”,&f);
return 0;
}

OUTPUT:
enter the 5numbers 20
25
26
35
55
average=117

|Page
|Page
Practical:7

AIM: Program to show swapping of 2 variables without using a third variable.

DESCRIPTION/THEORY:
 We will input two variables 10 and 20(we can change the input if we want to or else
add printf() command so the user can input any number by themselves).
 Then we will use a formula and swap two numbers and display both the results(before
swap and after swap).

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
Int x,y;
Printf(“enter the value of x”);
Scanf(“%d”,&x);
Printf(“enter the value of y”);
Scanf(“%d”,&y);
x=x+y;
y=x-y;
x=x+y;
printf(“after swapping x=%d”,x);
printf(“after swapping y=%d”,y);
return 0;
}

OUTPUT:
enter the value of x=25.
enter the value of y=45.

|Page
after swapping x=45.
after swapping y=25.

|Page
Practical:8

AIM: Program to show swapping of 2 numbers by using third variable.

DESCRIPTION/THEORY:
 Swapping means interchanging. here the process is same as we did in last practical
no:7but in this case we will be using a temporary variable in this to do so.

PROGRAM:
#include<stdio.h>
Int main()
{
Int a=50,b=20,c;
Printf(“before swapping a=%d,b=%d”,a,b);
c=a;
a=b;
b=c;
printf(“after swapping a=%d, b=%d”, a ,b);
return 0;
}

OUTPUT:
Before swap a=50,b=20
After swap a=20,b=50.

|Page
|Page
Practical:9

AIM: Program to show reverse of the given number.

DESCRIPTION/THEORY:
 A while loop is used to execute a piece of code while a condition is true.
 The while loop is to be used when a block of code is to be executed a variable number
of times.

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
Int num ,rem ,rev=0;
Printf(“enter the number”);
Scanf(“%d”,&num);
While(num!=0)
{
rem=num%10;
rev=rev*10+rem;
num=num/10;
}
Printf(“rev=%d”,rev);
return 0;
}

OUTPUT:
enter the number: 3456.
rev=6543.

|Page
|Page
Practical:10

AIM: Program to find the greatest among the 3 numbers.

DESCRIPTION/THEORY:
 We will be asking the user to input any 3 numbers of his choice and result will display
the greatest one of them using if statement.

PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
Printf(“enter the numbers a, b and c”);
Scanf(“%d%d%d”,&a,&b,&c);
If(a>=b&&a>=c)
Printf(“%d is largest number”,a);
If(b>=a&&b>=c)
Printf(“%d is largest number”,b);
If(c>=a&&c>=b)
Printf(“%d is largest number”,c);
return 0;
}

OUTPUT:
enter the numbers a,b,c: 78
89
96
96 is largest number.

|Page
|Page
Practical:11

AIM: Repeat the Practical no.10 using the Conditional Operator.

DESCRIPTION/THEORY:
 The syntax of conditional operator is condition?
 Value_if_true:value_if_false The conditional operator associates from right to left.
 Consider the following: exp1?exp2:exp3?exp4:exp5.
 As the association is from right to left, the above expression is evaluated as exp1?
exp2: ( exp3 ?exp4: exp5 ).

PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int a, b, c, largest;
printf(“enter the number a,b,c”);
scanf(“%d%d%d”,&a,&b,&c);
largest=a>b?a>c?a:c:b>c?b:c;
printf(“largest number is %d”,largest);
return 0;
}

OUTPUT:
enter the number a,b,c;78
155
230
largest number is 230.

|Page
|Page
Practical:12

AIM: Program to find that the entered year is leap year or not.

DESCRIPTION/THEORY:
 We can take the input from the user using scanf().
 Then using the if…else statement to check whether the year is a leap year or not.
 Then using printf() we will display the result.

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
Int year;
Printf(“enter the year”);
Scanf(“%d”,&year);
If(year%400==0)
{
Printf(“%d is a leap year”,year);
}
else if(year%100==0)
{
Printf(“%d is not a leap year”,year);
}
else if(year%4==0)
{
Printf(“%d is a leap year”,year);
}
else
{

|Page
Printf(“%d is not a leap year”,year);
}
return 0;
}

OUTPUT:1
enter the year: 2019
2019 is not a leap year.

OUTPUT:2
enter the year:2004
2004 is a leap year.

|Page
|Page
Practical:13

AIM: Program to find a given number is even or odd.

DESCRIPTION/THEORY:
 We will ask the user to input a number using scanf().
 Now, by using if…else statement we will check whether the entered number is even
or odd, then we will display the result using printf().
 In computer programming, we use the if statement to run a block code only when a
certain condition is met.
 The if statement evaluates the condition inside the parentheses ( ).

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
Int num;
printf(“enter an integer”);
scanf(“%d”,&num);
if(num%2==0)
printf(“%d is an even ”,num);
else
printf(“%d is an odd ”,num);
return 0;
}
OUTPUT1:
enter an integer: 2.
2 is an even.
OUTPUT2:
enter an integer: 5
5 is an odd

|Page
|Page
|Page
Practical:14

AIM: Program to display percentage of student using switch statement.

DESCRIPTION/THEORY:
 “switch” statements are useful when you want to have your program do many
different things according to the value of a particular test variable.
 The switch expression is evaluated once.
 The syntax for a switch statement in C is as follows;
Switch(expression)
{case constant -expression:statements;break ;
// optional case constant-expression:statements;break;//optional//you can have any
number of case statements.default://optional statement(s);}

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
Int score;
Printf(“enter the score(0-100):”);
Scanf(“%d”,&score);
Switch(score/10)
{
Case 10;
Case9;
Printf(“grade:A”);
break;
case8;
printf(“grade:B”);
break;
case7;

|Page
printf(“grade:C”);
break;
case6;
printf(“grade:D”);
break;
case5;
printf(“grade:E”);
break;
default:
printf(“grade:F”);
break;
}
return 0;
}

OUTPUT:
enter the score(0-100) : 80
grade: B

|Page
|Page
Practical:15

AIM: Program to display arithmetic operation using switch statement.

DESCRIPTION/THEORY:
 We will ask the user to input two number and the arithmetic operator.
 We will use the switch statement to calculate the operation. Then we will print it
using printf().
 The default statement is executed if no case constant-expression value is equal to the
value of expression.
 If there’s no default statement, and no case match is found, none of the statements in
the switch body get executed.
 There can be at most one default statement.

PROGRAM:
#include<stdio.h>
#Include<conio.h>
Int main()
{
Int a,b;
Int op;
Printf(“addition, subtraction, multiplication,division”);
Printf(“enter the values of a,b”);
Scanf(“%d%d”,&a&,b);
Printf(“enter the choice”);
Scanf(“%d”,op);
Switch(op)
{
case 1:
Printf(“sum of %d is %d”, a ,b , a+b);
break;
case 2:

|Page
printf(“difference of %d is %d”,a,b,a-b);
break;
case 3:
printf(“multiplication of %d is %d”,a,b,a*b);
break;
case 4:
printf(“division of %d is %d”,a,b,a/b);
default:
printf(“enter the correct choice”);
break;
}
return 0;
}

OUTPUT:1
Addition, subtraction, multiplication, division.enter the value a and b: 100,5
enter the choice:1
sum of 100 and 5 is 105.

OUTPUT:2
Addition, subtraction, multiplication, division. enter the value a and b:200,56
enter the choice:3
multiplication of 200 and 56 is 11200.

|Page
|Page
|Page
Practical:16

AIM: Program to display first 15 natural numbers and their sum using For Loop.

DESCRIPTION/THEORY:
 The for loop is to be used when a block of code is to executed a fixed number of
times.
 For Loop(Syntax):
For(statement 1;statement 2;statement3) {code block to be excuted}
Statement 1: is executed before the execution of code block.
Statement 2: defines the conditions for executing the code block.
Statement3:is executed after the code block has been executed.

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
int i,sum=0;
printf(“the first 10 natural number is”);
for(i=1;i<=15;i++)
{
Sum=sum+i;
Printf(“%d”,i);
}
Printf(“the sum is %d”,sum);
return 0;
}
OUTPUT:
The first 15 natural number is :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
The sum is : 120

|Page
|Page
Practical:17

AIM: Program to print Patterns.

DESCRIPTION/THEORY:
 The syntax of for loop is for (int i=0;i>=0; ){ /*body of the loop where I is not
changed*/}The for loop is to be used when a block of code is to executed a fixed
number of times.

PROGRAM:1
#include<stdio.h>
#include<conio.h>
Int main()
{
Int i,j,rows;
Printf(“enter the number of rows”);
Scanf(“%d”,&rows);
for(i=1;i<=rows;i++)
{
for(j=1;j<=I;j++)
{
Printf(“*”);
}
Printf(“\n”);
}
return 0;
}

|Page
OUTPUT:1
enter the number of rows:5
*
**
***
****
*****

|Page
Program:2
#include<stdio.h>
#include<conio.h>
Int main()
{
int I,j,rows;
printf(“enter the number of rows”);
scanf(“%d”,&rows);
for(i=1;i<=rows;i++)
{
for(j=1;j<=I;j++)
{
Printf(“%d”,j);
}
Printf(“\n”);
}
return 0;
}

OUTPUT:2
enter the number of rows: 5
1
12
123
1234
12345

|Page
|Page
Practical:18

AIM: Program to print Fibonacci series till 40.

DESCRIPTION/THEORY:
 We will use the for loop and some formulas to print the Fibonacci series.

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
int i,n;
int t1=0,t2=1;
int nextterm=t1+t2;
printf(“enter the number of terms”);
scanf(“%d”,&n);
printf(“Fibonacci series %d%d”,t1,t2);
for(i=2;i<=40;i++)
{
Printf(“%d”,nextterm);
t1=t2;
t2=nextterm;
nextterm=t1+t2;
}
return 0;
}

|Page
OUTPUT:

|Page
Practical:19

AIM: Program to find factorial of a given number.

DESCRIPTION/THEORY:
 We will use scanf() to get input from the user. Then using for loop and some of the
formula’s.
 Then we will print the result using printf().
 Factorial program in C :factorial of n is the product of all positive descending
integers. factorial of n is denoted by n!.

PROGRAM:
#include<stdio.h>
#include<conio.h>
Int main()
{
int fact=1;
int i,n;
printf(“enter the integer”);
scanf(“%d”,&n);
{
If(n<0)
Printf(“an integer is non negative”);
else
{
for(i=1;i<=n;i++)
fact=fact*I;
}
Printf(“fact=%d”,fact);
Scanf(“%d”,&fact);
}

|Page
return 0;
}

OUTPUT:
enter the integer: 5
fact=120

|Page
Practical:20

AIM: Program to find whether a given number is prime or not.

DESCRIPTION/THEORY:
 The syntax of if...else is if(expression){ //code to be executed if condition is
true}else{ //code to be executed if condition is false }.
 The if else statement is used to perform two operations for a single condition. The if
statement is an extension to the if statement else using which, we can perform two
different operations, i.e., one is for the correctness of that condition, and the other is
for the incorrectness of the condition.
 The break is used to bring the program control out of the loop. the break statement is
used inside loops or switch statement.

PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int i, n, flag=0;
printf(“enter the positive integer”);
scanf(“%d”,&n);
for(i=2;i<=n/2;i++)
{
If(n%i==0)
{
flag=1;
break;
}
}
If(n==1)
{

|Page
Printf(“1 is neither prime nor composite”);
}
else
{
If(flag==0)
Printf(“%d is a prime number”,n);
else
printf(“%d is not a prime number”,n);
}
return 0;
}

OUTPUT:1
enter the positive integer: 85
85 is not a prime number.

OUTPUT:2
enter the positive integer:89
89 is a prime number.

|Page
|Page
|Page

You might also like