0% found this document useful (0 votes)
14 views4 pages

C Basic Type Solved Programs

The document contains C programs to calculate the area and circumference of a circle, simple interest, greatest of 3 numbers, gross salary, electric bill amount, check odd/even, check leap year, and factorial of a number using a for loop.

Uploaded by

vickroid007
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)
14 views4 pages

C Basic Type Solved Programs

The document contains C programs to calculate the area and circumference of a circle, simple interest, greatest of 3 numbers, gross salary, electric bill amount, check odd/even, check leap year, and factorial of a number using a for loop.

Uploaded by

vickroid007
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

-: C Programs :-

C Program to find area and circumference of circle


#include<stdio.h>

int main()
{
int rad;
float PI=3.14,area,ci;

printf("nEnter radius of circle: ");


scanf("%d",&rad);

area = PI * rad * rad;


printf("nArea of circle : %f ",area);

ci = 2 * PI * rad;
printf("nCircumference : %f ",ci);

return(0);
}

C Program to find the simple interest


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

void main()
{
int amount,rate,time,si;
clrscr();

printf("nEnter Principal Amount : ");


scanf("%d",&amount);

printf("nEnter Rate of interest : ");


scanf("%d",&rate);

printf("nEnter Period of Time : ");


scanf("%d",&time);

si = (amount * rate * time)/100;

printf("Simple Intrest : %d",si);

getch();
}
C Program to find greatest in 3 numbers
#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,c;
clrscr();

printf("nEnter value of a, b & c: ");


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

if((a>b)&&(a>c))
printf("na is greatest");

if((b>c)&&(b>a))
printf("nb is greatest");

if((c>a)&&(c>b))
printf("nc is greatest");

getch();
}

C Program to calculate gross salary of a person.


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

void main()
{
int gross_salary,basic,da,ta;
clrscr();

printf("Enter basic salary : ");


scanf("%d",&basic);

da = ( 10 * basic ) / 100;
ta = ( 12 * basic ) / 100;

gross_salary = basic + da + ta;

printf("Gross salary : %d",gross_salary);


getch();
}
An electric power distribution company charges its domestic consumers as follows

Consumption Units Rate of Charge


0-200 Rs.0.50 per unit
201-400 Rs.100 plus Rs.0.65 per unit excess 200
401-600 Rs.230 plus Rs.0.80 per unit excess of 400.

Write a C program that reads the customer number and power consumed and prints the amount to be paid
by the customer.

#include<stdio.h>
#include<conio.h>
void main()
{
int n, p;
float amount;
clrscr();
printf("Enter the customer number: ");
scanf("%d",&n);
printf("Enter the power consumed: ");
scanf("%d",&p);

if(p>=0 && p<=200)


amount=p*0.50;
else if(p>200 && p<400)
amount = 100+((p-200) * 0.65);
else if(p>400 && p<=600)
amount = 230 + ((p-400) * 0.80);
printf("Amount to be paid by customer no. %d is Rs.:%5.2f.",n,amount);

getch();
}

C program to check odd or even using modulus operator


#include<stdio.h>
main()
{
int n;

printf("Enter an integer\n");
scanf("%d",&n);

if ( n%2 == 0 )
printf("Even\n");
else
printf("Odd\n");
return 0;
}
C program to check leap year
#include <stdio.h>

int main()
{
int year;

printf("Enter a year to check if it is a leap year\n");


scanf("%d", &year);

if ( year%400 == 0)
printf("%d is a leap year.\n", year);
else if ( year%100 == 0)
printf("%d is not a leap year.\n", year);
else if ( year%4 == 0 )
printf("%d is a leap year.\n", year);
else
printf("%d is not a leap year.\n", year);

return 0;
}
Factorial program in c using for loop
#include <stdio.h>
int main()
{
int c, n, fact = 1;

printf("Enter a number to calculate it's factorial\n");


scanf("%d", &n);

for (c = 1; c <= n; c++)


fact = fact * c;

printf("Factorial of %d = %d\n", n, fact);


return 0;
}

You might also like