0% found this document useful (0 votes)
7 views

24ITO051labfile

Uploaded by

24itp029
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

24ITO051labfile

Uploaded by

24itp029
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

1(a)

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 :

Conclusion : I learned how to print “HELLO WORLD”.


1(b)

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;

printf("enter 1st integer : ");


scanf("%d",&a);
printf("enter 2nd integer :
"); scanf("%d",&b);
printf("you enter integer %d and %d",a,b);
return 0;
}
Output :

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;

printf("enter the integer value of a");


scanf("%f",&a);
printf("enter the integer value of b");
scanf("%f",&b);

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 :

Conclusion : I learned how to use arithmetic operations in c programming.


2(b)

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;

printf("enter your basic


salary :"); scanf("%f",&basic);
da=0.5*basic;
hra=0.1*basic;
me=0.04*basic;
gs=basic+da+hra+me;
pf=0.05*gs;
in=0.07*gs;
dd=in+pf
; nt=gs-
dd;
printf("your net salary is : %f ",nt);
return 0;
}
Output :

Conclusion : I learned how to calculate salary of any employee.


2(c(i))

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;

printf("enter the value of a : ");


scanf("%d",&a);
printf("enter the value of b : ");
scanf("%d",&b);

c = a + b;
a = c - a;
b = c - a;

printf("the value of a : %d\


n",a); printf("the value of b :
%d\n",b); return 0;
}
Output :

Conclusion : I learned how to swap numbers using temporary variables.


2(c(ii))

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,;

printf("enter the value of a : ");


scanf("%d",&a);
printf("enter the value of b : ");
scanf("%d",&b);

a = a + b;
b = a - b;
a = a - b;

printf("the value of a : %d\


n",a); printf("the value of b :
%d\n",b); return 0;
}
Output :

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;

printf("enter the value of a :");


scanf("%d",&a);
printf("enter the value of b :");
scanf("%d",&b);
max = a>b?a:b;

printf("the greater of %d and %d is %d",a,b,max);


return 0;
}
Output :

Conclusion : I learned how to use ternary operation in c programming.

You might also like