0% found this document useful (0 votes)
3 views14 pages

Expriment No.-: Title-Name - Roll No - Class - PRN No. - Subj

The document contains a series of programming experiments conducted by Riya Ravindra Phadatare, focusing on various programming concepts such as if-else statements, switch cases, loops, functions, and file handling. Each experiment includes code snippets, outputs, and a vision and mission statement for the department aimed at promoting academic and holistic development of students. The experiments demonstrate practical applications of programming in C, showcasing skills necessary for industry readiness.

Uploaded by

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

Expriment No.-: Title-Name - Roll No - Class - PRN No. - Subj

The document contains a series of programming experiments conducted by Riya Ravindra Phadatare, focusing on various programming concepts such as if-else statements, switch cases, loops, functions, and file handling. Each experiment includes code snippets, outputs, and a vision and mission statement for the department aimed at promoting academic and holistic development of students. The experiments demonstrate practical applications of programming in C, showcasing skills necessary for industry readiness.

Uploaded by

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

Expriment No.

- 3
Title- Program for if - else statement

Name - Riya Ravindra Phadatare Roll No- 232


Class- FY B.TECH CSE PRN No.- 24067571242119
Subj- programming for problem solving

#include<stdio.h>
int main(){
int num;
setbuf(stdout,NULL);
printf("enter number :");
scanf("%d",&num);
if(num%2==0){
printf("given number is even number");
}
else{
printf("given number is odd number");
}
}

Output
enter number :
35
given number is odd number

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 3
Title- Program for simple calculator using switch case

Name - Riya Ravindra Phadatare Roll No- 232


Class- FY B.TECH CSE PRN No.- 24067571242119
Subj- programming for problem solving

#include <stdio.h>
int main() {
char op;
int num1, num2;
setbuf(stdout,NULL);
printf("Enter an operator (+, -, *, /): ");
scanf("%c", &op);
printf("Enter two operands: ");
scanf("%d %d", &num1, &num2);
switch (op) {
case '+':
printf("%d + %d = %.d", num1,num2,num1+num2);
break;
case '-':
printf("%d + %d = %.d", num1,num2,num1+num2);
break;
case '*':
printf("%d + %d = %.d", num1,num2,num1+num2);
break;
case '/':
printf("%d + %d = %.d", num1,num2,num1+num2);
break;
// operator doesn't match any case constant
Default:
printf("Error! operator is not correct");
}
return 0;
}

Outut :
Enter an operator (+, -, *, /): +
Vision:Enter
To be
twoanoperands:
excellent department
10 20 of the institute promoting academic as well
as holistic
10 +development
20 = 30 of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 3
Title- Program read a number and display its reverse using while loop

Name - Riya Ravindra Phadatare Roll No- 232


Class- FY B.TECH CSE PRN No.- 24067571242119
Subj- programming for problem solving

#include<stdio.h>
int main()
{
int i=10;
while(i>=1)
{
printf(“%d \n”,i);
i--;
return 0;
}

Output :
10
9
8
7
6
5
4
3
2

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 4
Title- Program to calculate the factorial of a given number and display the result

Name - Riya Ravindra Phadatare Roll No- 232


Class- FY B.TECH CSE PRN No.- 24067571242119
Subj- programming for problem solving

#include<stdio.h>
int fact(int f);
int main()
{
int n,factorial;
setbuf(stdout,NULL);
printf(“Enter a number to find factorial”);
scanf(“%d”,&n);
factorial= fact(n);
printf("Factorial of a Given Number is: %d ",factorial);
return 0;
}
int fact(int f)
{
int fact=1;
for(i=1; i<=f; i++)
{
fact=fact*i;
}
return fact;
}

Output :

Factorial of a Given Number is: 6

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 5
Title- Program for sum of digits of numbers

Name - Riya Ravindra Phadatare Roll No- 232


Class-FY B.TECH CSE PRN No.- 24067571242119
Subj- programming for problem solving

#include<stdio.h>
int sum(int n);
int main()
{
int num, result;
printf(“Enter a number:”);
scanf(“%d”,&num);
result = sum(num);
printf(“Sum of natural numbers :%d\n”,result);
return 0;
}
int sum(int n)
{
int k;
if(n==0)
{
return 0;
}
k = n +sum(n-1);
return (k);
}

Output :
Enter a number:3
Sum of natural numbers : 6

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 6
Title- Program to find length of string

Name - Riya Ravindra Phadatare Roll No- 232


Class- FY B.TECH CSE PRN No.- 24067571242119
Subj- programming for problem solving

#include <stdio.h>
#include <string.h>
int main()
{
int len1, len2;

// Declare and initialize a character array 'str'

char arr[] = "Humpty";


// Calculate the length of the string using the strlen()
len1 = strlen(arr);
// Print the length of the string
printf("Length1: %s\n", len1);
len2 = strlen(arr);
// Print the length of the string
printf("Length2: %s\n", len2);
return 0;
}

Output :
Length : 13
Length : 13

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 6
Title- Program for copy one string to another string

Name - Riya Ravindra Phadatare Roll No- 232


Class- fy b.tech cse PRN No.- 24067571242119
Subj- pps

#include <stdio.h>
#include <string.h>
int main()
{
// defining strings
char source[] = "Humpty";
char target[20];
// Copying the source string to dest
strcpy(target, source);
// printing result
printf("Source: %s\n", source);
printf("Target: %s\n", target);
return 0;
}
Output :
Source : Humpty
Target : Humpty

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 6
Title- Program to illustrate the strcat function

Name - Riya Ravindra Phadatare Roll No- 232


Class- fy b.tech cse PRN No.- 24067571242119
Subj- pps

#include <stdio.h>
int main()
{
char target[50] = "PPS";
char source[50] = " Welcome";
// concatenating src at the end of dest
strcat(target,source);
printf("Source: %s\n", source);
printf("Target: %s\n", target);
return 0;
}

Output :
Source : PPS
Target: WelcomePPS

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 7
Title- program for addition of two dimensional matrices using multidimensional

Name - Riya Ravindra Phadatare Roll No- 232


Class- fy b.tech cse PRN No.- 24067571242119
Subj- pps

#include <stdio.h>
int main() {
int matrix1[2][2]={{1,2},{3,4}};
int matrix2[2][2]={{5,6},{7,8}};
,int sum[2][2];
// Add the two matrices
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
sum[i][j] = matrix1[i][j] + matrix2[i][j];
}
}
// Display the result
printf("Resultant 2x2 Matrix:\n");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
printf("%d ", sum[i][j]);
}
printf("\n");
}
return 0;
}

Output:
Resultant 2x2 Matrix:
68
10 12

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 8
Title- Program to swap two numbers using pointers

Name - Riya Ravindra Phadatare Roll No- 232


Class- fy b.tech cse PRN No.- 24067571242119
Subj- pps

#include <stdio.h>
int main() {
int num1, num2, temp;
int *ptr1 = &num1, *ptr2 = &num2;
printf("Enter two numbers:\n");
scanf("%d %d", &num1, &num2);
printf("Before swapping: num1 = %d, num2 = %d\n", *ptr1, *ptr2);
temp = *ptr1;
*ptr1 = *ptr2;
*ptr2 = temp;
printf("After swapping: num1 = %d, num2 = %d\n", *ptr1, *ptr2);
return 0;
}

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 9
Title- Program to represent a student record

Name - Riya Ravindra Phadatare Roll No- 232


Class- fy b.tech cse PRN No.- 24067571242119
Subj- pps

#include <stdio.h>
struct Student
{
int rollno;
char name[50];
float marks;
};
int main()
{
struct Student s1;
setbuf(stdout,NULL);
printf("Enter roll number: ");
scanf("%d", &s1.rollno);
printf("Enter name: ");
scanf("%s", s1.name);
printf("Enter marks: ");
scanf("%f", &s1.marks);
printf("\n--- Student Details ---\n");
printf("Roll Number: %d\n", s1.rollno);
printf("Name: %s\n", s1.name);
printf("Marks: %.2f\n", s1.marks);
return 0;
}
Output :
Enter roll number 11
Enter name : john
Enetr marks : 76.8
Student Details
Roll number :11
Vision: To be an excellent department of the institute promoting academic as well
Name :john
as holistic development of students and
Marks:76.8 encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 10
Title- File open in read mode.

Name - riya ravindra phadtare Roll No- 232


Class- fy b.tech cse PRN No.- 24067571242119
Subj- pps

#include<stdio.h>
int main()
{
FILE *fp;
fp=fopen("test.txt","r");
if(fp != NULL)
{
printf("File open successfull");
}
else
{
printf("File open unsuccessfull");
}
return 0;
}

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 10
Title- Read content from file

Name - Riya Ravindra Phadatare Roll No- 232


Class- FY B.TECH CSE PRN No.- 24067571242119
Subj- programming for problem solving

#include<stdio.h>
int main()
{
FILE *fp;
char content[1000];
fp=fopen("test.txt","r");
if(fp != NULL)
{
fgets(content,1000,fp);
printf("%s",content);
}
else
{
printf("File open unsuccessfull");
}
return 0;
}

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities
Expriment No.- 10
Title- Writing in a file

Name - Riya Ravindra Phadatare Roll No- 232


Class- FY B.TECH CSE PRN No.- 24067571242119
Subj- PPS

#include<stdio.h>
int main()
{
FILE *fp;
fp=fopen("newfile.txt","w");
fputs("I love c programmimg",fp);
fclose(fp);
return 0;
}

Vision: To be an excellent department of the institute promoting academic as well


as holistic development of students and
encouraging their creative potential.
Mission: M1: To develop technical and communicative skills to make the students
industry ready.
M2: To promote innovation and research for catering to the needs of the
society at large
M3: To inculcate ethical values and promote social responsibility through
an innovative learning process in basic
sciences and humanities

You might also like