Programming With C File
Programming With C File
Laboratory Manual
of
Programming with C
is submitted to
Assistant Professor
Semester — 1
(Winter 2024)
CERTIFICATE
has satisfactorily completed his/her laboratory work of Programming with C during regular
Date of Submission:
Department Authority
Mrs. Halak Patel
Subject Teacher
Assistant Professor
Department of Computer Science and Engineering
Institute Stamp
Asha M. Tarsadia Institute of Computer Science and
Technology
Uka Tarsadia University
INDEX
Practical Title Date Sign
No.
1 Write a C program to show the usage of printf function.
Practical 1
Code :
/************************************************
Student Name: Akash Saxena
Branch: B.Tech CE
Enrollment Number: 202403103510359
************************************************/
#include <stdio.h>
int main() {
int age = 69;
float height = 5.9;
char name[] = "Akash Saxena";
return 0;
}
Output :
Practical 2
AIM : Write a C program to print basic student details using library function -
printf().
************************************************
Student Name:
Branch:
Enrollment Number:
************************************************
Code :
#include <stdio.h>
int main() {
printf("************************************************\n");
printf("Student Name: %s\n", name);
printf("Branch: %s\n", branch);
printf("Enrollment Number: %ld\n", enrollment_number);
printf("************************************************\n");
return 0;
}
Output :
Practical 3
AIM : Write a C program that takes user-entered number and print the same number
on a terminal screen
Code :
/************************************************
Student Name: Akash Saxena
Branch: B.Tech CE
Enrollment Number: 202403103510359
************************************************/
#include <stdio.h>
int main() {
int number;
return 0;
}
Output :
Practical 4
AIM : Write a C program to take two integers from the user and perform arithmetic
operations (addition, subtraction, division and multiplication) of two
numbers.
Code :
/************************************************
Student Name: Akash Saxena
Branch: B.Tech CE
Enrollment Number: 202403103510359
************************************************/
#include <stdio.h>
int main() {
int num1, num2;
int sum, difference, product;
float quotient;
if (num2 != 0) {
printf("Division: %.2f\n", quotient);
} else {
return 0;
}
Output :
Practical 5
AIM : Write a C program to take temperature from the user in F and display the
temperature in C.
Code :
/************************************************
Student Name: Akash Saxena
Branch: B.Tech CE
Enrollment Number: 202403103510359
************************************************/
#include <stdio.h>
int main() {
float fahrenheit, celsius;
return 0;
}
Output :
Practical 6
AIM : Write a C program to display the area as an output of various shapes (circle
and rectangle) to the user. User will enter necessary parameter values.
Code :
/************************************************
Student Name: Akash Saxena
Branch: B.Tech CE
Enrollment Number: 202403103510359
************************************************/
#include <stdio.h>
#define PI 3.14159
int main() {
int choice;
float area;
switch (choice) {
case 1: // Circle
{
float radius;
printf("Enter the radius of the circle: ");
scanf("%f", &radius);
area = PI * radius * radius;
printf("Area of the circle: %.2f\n", area);
break;
}
case 2: // Rectangle
{
return 0;
}
Output :
Practical 7
AIM : Write a C program that scan an integer from the user and check whether the
number is divisible by 3 or not.
Code :
/************************************************
Student Name: Akash Saxena
Branch: B.Tech CE
Enrollment Number: 202403103510359
************************************************/
#include <stdio.h>
int main() {
int number;
if (number % 3 == 0) {
printf("%d is divisible by 3.\n", number);
} else {
printf("%d is not divisible by 3.\n", number);
}
return 0;
}
Output :
Practical 8
AIM : Write a C program to take inputs of Month and Year from the user and modify
it in such a way that prints month name given the month number by the user.
(e.g. Input: Month: 03, Year: 2023 Output: Month: March)
Code :
/************************************************
Student Name: Akash Saxena
Branch: B.Tech CE
Enrollment Number: 202403103510359
************************************************/
#include <stdio.h>
int main() {
int month, year;
printf("Month: ");
switch (month) {
case 1:
printf("January\n");
break;
case 2:
printf("February\n");
break;
case 3:
printf("March\n");
break;
case 4:
printf("April\n");
break;
case 5:
printf("May\n");
break;
case 6:
printf("June\n");
break;
case 7:
printf("July\n");
break;
case 8:
printf("August\n");
break;
case 9:
printf("September\n");
break;
case 10:
printf("October\n");
break;
case 11:
printf("November\n");
break;
case 12:
printf("December\n");
break;
default:
printf("Invalid Month!\n");
}
return 0;
}
Output :
Practical 9
AIM : Write a C program to take three integers from the user and print the largest
among them.
Code :
/************************************************
Student Name: Akash Saxena
Branch: B.Tech CE
Enrollment Number: 202403103510359
************************************************/
#include <stdio.h>
int main() {
int num1, num2, num3;
return 0;
}
Output :
Practical 10
AIM : Write a C program that display the grade of the student given the marks.
Code :
/************************************************
Student Name: Akash Saxena
Branch: B.Tech CE
Enrollment Number: 202403103510359
************************************************/
#include <stdio.h>
int main() {
float marks;
return 0;
Output :