0% found this document useful (0 votes)
23 views8 pages

Date: 10/01/2022 PROGRAM 1: Write A C Program To Add Two Numbers

The document contains 8 C programming examples covering topics like addition, arithmetic operations, area of a circle, average of numbers, simple interest, checking eligibility to vote, and checking equality of numbers. Each example includes the code with comments and output.

Uploaded by

Keren Elisheba
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)
23 views8 pages

Date: 10/01/2022 PROGRAM 1: Write A C Program To Add Two Numbers

The document contains 8 C programming examples covering topics like addition, arithmetic operations, area of a circle, average of numbers, simple interest, checking eligibility to vote, and checking equality of numbers. Each example includes the code with comments and output.

Uploaded by

Keren Elisheba
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/ 8

Date: 10/01/2022

PROGRAM 1: Write a C program to add two numbers

#include <stdio.h>

void main()

int a,b,c;

printf("enter the values for a and b ");

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

c=a+b;

printf("Addition of %d and %d are %d",a,b,c);

}
Date: 10/01/2022

PROGRAM 2: Write a C program to calculate all the arithmetic operations

#include <stdio.h>

void main()

float a,b,c,d,e,f;

printf("enter the value of a and b\n");

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

c=a+b;

d=a-b;

e=a*b;

f=a/b;

printf("Addition of %f and %f are %f \n",a,b,c);

printf("Subtraction of %f and %f are %f \n",a,b,d);

printf("Multiplication of %f and %f are %f \n",a,b,e);

printf("Division of %f and %f are %f \n",a,b,f);

}
14/01/2022

Program 3: Write a C program to calculate the area of a circle

#include <stdio.h>

void main()

float r,area;

printf("enter the radius of the circle \n");

scanf("%f",&r);

area=3.14*r*r;

printf("area of circle= %f",area);

}
Program 4: Write a C program to calculate the average of 5 numbers;

#include <stdio.h>

void main()

int a,b,c,d,e,avg;

printf("enter 5 numbers");

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

avg=(a+b+c+d+e)/5

printf("The average of 5 numbers is = %d",avg);

}
PROGRAM 5: Write a C program to calculate Simple Interest

#include <stdio.h>

void main()

float SI,P,R,T;

printf("enter the principal amount");

scanf("%f",&P);

printf("enter the rate of interest");

scanf("%f",&R);

printf("enter the time");

scanf("%f",&T);

SI=P*R*T;

printf("The Simple Interest is = %f",SI);

}
PROGRAM 6:
DATE: 21/01/2022

PROGRAM 7: C Program to find if a person is eligible to vote

#include <stdio.h>

void main()
{
int age;
printf("enter your age");
scanf("%d",&age);
if(age>=18)
{
printf("you are eligible to vote");
}
else
{
printf("you are not eligible to vote");
}
}

OUTPUT:
DATE: 21/01/2022

PROGRAM 8: Write a C Program to check if 2 numbers are equal


#include <stdio.h>

void main()
{
int a,b;
printf("enter 2 numbers");
scanf("%d %d",&a,&b);
if(a==b)
{
printf("numbers are equal");
}
else
{
printf("numbers aren't equal");
}
}

You might also like