0% found this document useful (0 votes)
31 views10 pages

Lab Report 1

lab report for IT students

Uploaded by

rishavkhadka43
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)
31 views10 pages

Lab Report 1

lab report for IT students

Uploaded by

rishavkhadka43
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/ 10

LAB REPORT 1

1) Write a program to display “TEXAS INTERNATIONAL COLLEGE.”

Program to display Texas International College is listed below:

#include <stdio.h>

int main()
{
printf(“Texas International College”);

return 0;
}

2) Write a program to add, subtract, multiply, and divide two whole numbers.

Program to add, subtract, multiply, and divide two whole number is listed below:

#include<stdio.h>
#include<conio.h>

int main()
{
int num1, num2, res;
printf(“Enter any two whole number:”);
scanf(“%d%d”, &num1, &num2);
res = num1+num2;
printf(“\n Addition = %d”, res);
res = num1-num2;
printf(“\n subtraction = %d”, res);
res = num1*num2;
printf(“\n Multiplication = %d”, res);
res = num1/num2;
printf(\n Division = %d”, res);
getch();
return 0;
}

3) Write a program to find simple interest.

Program to find simple interest is listed below:


# include <conio.h>
# include <stdio.h>
# include <stdlib.h>

int main()
{

//Simple interset program


int principal, rate, time, interest;

printf("Enter the principal: ");


scanf("%d", &principal);

printf("Enter the rate: ");


scanf("%d", &rate);

printf("Enter the time: ");


scanf("%d", &time);

interest = principal * rate * time / 100;


printf("The Simple interest is %d", interest);

return 0;
}

4) Write a program to convert a temperature given in celcius to Fahrenheit.

Program to convert a temperature given in celcius to Fahrenheit is listed below:

#include<stdio.h>

int main()
{
float celcius, fahrenheit;
printf("enter temperature in celcius:");
scanf("%f", &celcius);

fahrenheit = (celcius*1.8) + 32;


printf("%.2f celcius = %.2f fahrenheit", celcius, fahrenheit);
return 0;
}

5) Write a program to find square root of a given number.


Program to find square root of s given number is listed below:

#include<stdio.h>
#include<math.h>

int main(){
double num, root;

printf("Enter an integer:");
scanf("%lf", &num);
root = sqrt (num);

printf("THE SQUARE ROOT OF %.2lf = %.2lf", num, root);


return 0;
}

6) Write a program to find the power of a given number.

Program to find the power of a given number is listed below:

#inlcude<stdio.h>

int main() {
int base, exp;
long double result = 1.0;

printf(“Enter a base number:”);


scanf(“%d”, &base);
printf(“Enter an exponent:”);
scanf(“%d”, &exp);

While (exp != 0) {
result *= base;
--exp;
}
printf(“Answer = %.0Lf”, result);
return 0;
}

7) Write a program to find the area and circumference of a circle.

Program to find the area and circumference of a circle is listed below:


#include<stdio.h>

int main() {
float pi=3.14, area, circumference, radius;

printf("Enter radius of circle:");


scanf("%f", &radius);
area = pi * radius * radius;

printf("Area of circle is: %f\n",area);


circumference = 2 * pi * radius;
printf("Circumference of circle is: %f\n",circumference);

return 0;
}

8) Write a program to find the area and perimeter of a rectangle.

Program to find the area and perimeter of a rectangle is listed below:

#include <stdio.h>

void main() {
float length, width, perimeter, area;

printf("Enter the length of the Rectangle:\n");


scanf("%f", & length);
printf("Enter the width of the Rectangle:\n");
scanf("%f", & width);

perimeter = 2 * (length + width);


printf("Perimeter of the Rectangle: %0.4f\n", perimeter);

area = length * width;


printf("Area of the Rectangle: %0.4f\n", area);
}

9) Write a program to find the area of a triangle.

Program to find the area of a triangle is listed below:

#include <stdio.h>
int main() {
float base, height, area;

printf("Enter the base of the triangle: ");


scanf("%f", &base);

printf("Enter the height of the triangle: ");


scanf("%f", &height);

area = (base * height) / 2;

printf("The area of the triangle is: %.2f\n", area);

return 0;
}

10) Write a program to convert pounds to kilograms.

Program to convert pounds to kilograms is listed below:

#include<stdio.h>

int main()
{
float KG = 0.453592, pound;

printf("Enter weight in pounds\n");


scanf("%f", &pound);

printf("Weight in Kilograms is %f\n", (pound * KG) );

return 0;
}

11) Write a program to print six digit integer in reverse order.

Program to print six digit integer in reverse order is listed below:

#include <stdio.h>

int main() {

int n, reverse = 0, remainder;


printf("Enter any six digit integer: ");
scanf("%d", &n);

while (n != 0) {
remainder = n % 10;
reverse = reverse * 10 + remainder;
n /= 10;
}

printf("Reversed number = %d", reverse);

return 0;
}

12) Write a program to find the rupee equivalent of dollars.

Program to find the rupee equivalent of dollars is listed below:

#include <stdio.h>

int main(void) {
float dollars;

printf("Please enter dollars:");


scanf("%f", &dollars);

float rupees = dollars * 70;

printf("%f Rupees", rupees);


}

13) Write a program to express a length given in kilometers in meters, centimeters, millimeters.

Program to express a length given in kilometers in meters, centimeters, and millimeters is listed
below:

#include <stdio.h>

int main()
{
float Millimeter, Centimeter, Meter, Kilometer;

printf("\n Please Enter the Length in Kilometers (km) : ");


scanf("%f", &Kilometer);

Meter = Kilometer * 1000;


Centimeter = Kilometer * 100000;
Millimeter = Kilometer * 1000000;

printf("\n %.2f Kilometers = %.2f Meters", Kilometer, Meter);


printf("\n %.2f Kilometers = %.2f Centimeters", Kilometer, Centimeter);
printf("\n %.2f Kilometers = %.2f Millimeters", Kilometer, Millimeter);

return 0;
}

14) Write a program to swap two numbers using temporary variable.

Program to swap two numbers using temporary variables is listed below:

#include<stdio.h>

int main() {
int x, y, temp;
printf("Enter the value of x and y: ");
scanf("%d %d", &x, &y);
printf("Before swapping x=%d, y=%d ", x, y);

/*Swapping logic */
temp = x;
x = y;
y = temp;
printf("After swapping x=%d, y=%d", x, y);
return 0;
}

15) Write a program to swap two numbers without using temporary variable.

Program to swap two numbers without using temporary variables:


#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);

printf("Before swapping a: %d, b: %d\n",a,b);

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

printf("After swapping a: %d, b: %d\n",a,b);

return 0;
}

16) Write a program to find the square and cube of a given number.

Program to find the square and cube of a given number is listed below:

#include <stdio.h>

int main()
{
int no;
printf("Enter a number : ");
scanf("%d", &no);

printf("Square of %d is %d\n", no, (no * no));


printf("Cube of %d is %d\n", no, (no * no * no));
}

17) Write a program to calculate percentage of a student with makrs of 5 subjects.

Program to calculate percentage of a student with marks of 5 subjects is listed below:

#include <stdio.h>

int main()
{
float eng, phy, chem, math, comp;
float total, average, percentage;

printf("Enter marks of five subjects: :- ");


scanf("%f%f%f%f%f", &eng, &phy, &chem, &math, &comp);
total = eng + phy + chem + math + comp;
average = total / 5.0;
percentage = (total / 500.0) * 100;

printf("Total marks = %.2f\n", total);


printf("Average marks = %.2f\n", average);
printf("Percentage = %.2f", percentage);

return 0;
}

18) Write a program to sum the digit of as positive integer which is 5 digits long.

Program to sum the digit of a positive integer which is 5 digits long is listed below:

#include <stdio.h>
int main()
{
int n, t, sum = 0, remainder;

printf("Enter 5 digit integer : \n");


scanf("%d", &n);

t = n;

while (t != 0)
{
remainder = t % 10;
sum = sum + remainder;
t = t / 10;
}

printf("Sum of digits of %d = %d\n", n, sum);

return 0;
}

19) Write a program to find price of n mangos given the price of dozen mangos.

Program to find the price of n mangos given the price of dozen mangos is listed below:

#include <stdio.h>

int main() {
// Declare variables
float dozenPrice, mangoPrice;

// Input the price of a dozen mangos


printf("Enter the price of a dozen mangos: ");
scanf("%f", &dozenPrice);

// Calculate the price of one mango


mangoPrice = dozenPrice / 12;

// Display the result


printf("The price of 1 mango is: %.2f\n", mangoPrice);

return 0;
}

20) Write a program to show the use of typedef in c language.

Program to show the use of typedef in c language is listed below:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy