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

Programs

programs

Uploaded by

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

Programs

programs

Uploaded by

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

#include <stdio.

h>

#include <conio.h>

int main() {

int age = 25;

float height = 5.9;

clrscr();

printf("I am %d years old and my height is %.1f feet.\n", age, height);

getch();

return 0;

//addition

#include <stdio.h>

#include <conio.h>

int main() {

int a, b, sum;

clrscr();

printf("Enter two numbers: ");

scanf("%d %d", &a, &b);

sum = a + b;

printf("Sum: %d\n", sum);

getch();

return 0;

//Area of a Circle

#include <stdio.h>

#include <conio.h>

int main() {

float radius, area;

clrscr();

printf("Enter the radius of the circle: ");

scanf("%f", &radius);

area = 3.14 * radius * radius;


printf("Area of the circle: %.2f\n", area);

getch();

return 0;

Area of a Rectangle

#include <stdio.h>

#include <conio.h>

int main() {

float length, width, area;

clrscr();

printf("Enter the length and width of the rectangle: ");

scanf("%f %f", &length, &width);

area = length * width;

printf("Area of the rectangle: %.2f\n", area);

getch();

return 0;

Average of Three Numbers

#include <stdio.h>

#include <conio.h>

int main() {

float num1, num2, num3, average;

clrscr();

printf("Enter three numbers: ");

scanf("%f %f %f", &num1, &num2, &num3);

average = (num1 + num2 + num3) / 3;

printf("Average: %.2f\n", average);

getch();

return 0;

Find the Largest Number


#include <stdio.h>

#include <conio.h>

int main() {

int num1, num2, num3;

clrscr();

printf("Enter three numbers: ");

scanf("%d %d %d", &num1, &num2, &num3);

if (num1 >= num2 && num1 >= num3)

printf("The largest number is %d\n", num1);

else if (num2 >= num1 && num2 >= num3)

printf("The largest number is %d\n", num2);

else

printf("The largest number is %d\n", num3);

getch();

return 0;

Swap Two Numbers

#include <stdio.h>

#include <conio.h>

int main() {

int a, b, temp;

clrscr();

printf("Enter two numbers: ");

scanf("%d %d", &a, &b);

// Swapping

temp = a;

a = b;

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

getch();

return 0;

/*
* Add two integers and print their sum (Add2Integers.c)
*/
#include <stdio.h>
#include <conio.h>

int main() {
int integer1; // Declare a variable named integer1 of the type
integer
int integer2; // Declare a variable named integer2 of the type
integer
int sum; // Declare a variable named sum of the type integer

integer1 = 55; // Assign value to variable integer1


integer2 = 66; // Assign value to variable integer1
sum = integer1 + integer2; // Compute the sum

// Print the result


printf("The sum of %d and %d is %d.\n", integer1, integer2, sum);
getch();
return 0;
}

You might also like