24ITO051labfile
24ITO051labfile
Date :07/09/2024
Roll no. : 24ITO051
Name : Pruthviraj mori
Course code and name : 1CS501 – COMPUTER PROGRAMING
Practical no. : 1(a)
Aim : Demonstration and code blocks IDE. Make use of code blocks to write and compile a simple C program
(“HELLO WORLD”).
Methodology followed:
#include <stdio.h>
void main()
{
printf("HELLO WORLD");
Return 0;
}
Output :
Date :07/09/202
4 Roll no. :
24ITO051
Name : Pruthviraj Mori Course code and name : 1CS501 – COMPUTER PROGRAMING
Practical no. : 1(b)
Aim : Illustrate the use of scanf and printf function to read and display values of different types of variables, address of a variable in C language.
Methodology followed:
#include<stdio.h>
int main()
{
int
a;
int
b;
Conclusion : I learned how to assigned variables and use scanf and printf function in C programing.
1(c)
Date :07/09/202
4 Roll no. :
24ITO051
Name : Pruthviraj Mori
Course code and name : 1CS501 – COMPUTER PROGRAMING
Practical no. : 1(c)
Aim : to demonstrate escape sequences.
Methodology followed:
#include<stdio.h>
void main()
{
printf("MY NAME IS pruthviraj\n");
printf("MY NAME IS \t pruthviraj\n");
printf("MY NAME IS \b pruthviraj\n");
printf("MY NAME IS \r pruthviraj\n");
printf("MY NAME IS \a pruthviraj\n");
printf("MY NAME IS \'pruthviraj\n");
printf("MY NAME IS \\pruthviraj\n");
printf("MY NAME IS \? pruthviraj\n");
printf("MY NAME IS \"pruthviraj\n");
printf("MY NAME IS \n \0 pruthviraj\n");
printf("MY NAME IS \nnn pruthviraj\n");
return 0;
}
Output :
Conclusion : I learned different types of escape sequences.
2(a)
Date :07/09/2024
Roll no. : 24ITO051
Name : Pruthviraj Mori Course code and name : 1CS501 – COMPUTER PROGRAMING
Practical no. : 2(a)
Aim : To scan two numbers and display result of different arithmetic operations (+ , - , * , / and %)
Methodology followed:
#include<stdio.h>
#include<math.h
> int main()
{
float a,b,sum,substraction,multiplication,div;
sum = a + b;
substraction = a - b;
div = a / b;
multiplication = a * b;
printf("the sum is : %.0f\n",sum);
printf("the substraction is : %.0f\n",substraction);
printf("the div is %f\n",div);
printf("the multiplication is %.0f\n",multiplication);
return 0;
}
Output :
Date :07/09/2024
Roll no. : 24ITO051
Name : Pruthviraj Mori
Course code and name : 1CS501 – COMPUTER PROGRAMING
Practical no. : 2(b)
Aim : To calculate net salary of employee.
Methodology followed:
#include<stdio.h>
int main()
{
float basic,dd,da,hra,me,in,pf,nt,gs;
Date :07/09/2024
Roll no. : 24ITO051
Name : Pruthviraj Mori
code and name : 1CS501 – COMPUTER PROGRAMING
Practical no. : 2(c(i))
Aim : to swap the value of two numbers (i) using temporary variables.
Methodology followed:
#include<stdio.h>
int main()
{
int a,b,c;
c = a + b;
a = c - a;
b = c - a;
Date :07/09/2024
Roll no. : 24ITO051
Name : Pruthviraj Mori
Course code and name : 1CS501 – COMPUTER PROGRAMING
Practical no. : 2(c(ii))
Aim : to swap the value of two numbers (ii) without using temporary variables.
Methodology followed:
#include<stdio.h>
int main()
{
int a,b,;
a = a + b;
b = a - b;
a = a - b;
Conclusion : I learned how to swap numbers without using any third variables.
2(d)
Date :07/09/2024
Roll no. : 24ITO051
Name : Pruthviraj Mori
Course code and name : 1CS501 – COMPUTER PROGRAMING
Practical no. : 2(d)
Aim : To find the greatest of two numbers using the ternary operator.
Methodology followed :
#include<stdio.h>
int main()
{
int a,b,max;