HTML Tutorial || Networking Assignment || Computer Full Forms || Ms-Office Shortcut Keys || Ms-Office Notes || Number System Notes || Internet Assignment
JavaScript Tutorial || CSS Tutorial || Operating System Notes || History of Computer Assignment || Netwoking Notes || Computer Fundamentals Notes

C program to Convert Days into Years, Weeks and Days ?


Q:- Write a C Program to Convert Days into Years, Weeks and Days ?
Input
#include<stdio.h>
#include<<conio.h>
int main()
{
int days,years,weeks;
clrscr();
printf(“Enter a Number of Days=”);
scanf(“%d”,&days);
years=(days/365);
weeks=(days%365)/7;
days=days-((years*365)+(weeks*7));
printf(“Years=%d\n”,years);
printf(“Weeks=%d\n”,weeks);
printf(“Days=%d\n”,days);
getch();
}


Output

Enter a Number of days = 373
Years = 1
Weeks = 1
Days = 1

C Program to Enter P,T,R and Calculate Compound Interest ?


Q:- Write a C Program to Enter P,T,R and Calculate Compound Interest ?
Input

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
float principle,time,rate,ci;
clrscr();
printf("Enter Principle (Amount) =");
scanf("%f",&principle);
printf("Enter Time =");
scanf("%f",&time);
printf("Enter Rate =");
scanf("%f",&rate);
ci=()principle*time*rate/100;
printf("Compound Interest =%.2f",ci);
getch();
       }


Output

Enter principle(Amount) = 1200
Enter Time = 2
Enter Rate = 5.4
Compound Interest = 129.60

C Program to Enter P,T,R and Calculate Simple Interest ?


Q:- Write a C Program to Enter P,T,R and Calculate Simple Interest ?
Input

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
float principle,time,rate,si;
clrscr();
printf("Enter Principle (Amount) =");
scanf("%f",&principle);
printf("Enter Time =");
scanf("%f",&time);
printf("Enter Rate =");
scanf("%f",&rate);
si=()principle*time*rate/100;
printf("Simple Interest =%.2f",si);
getch();
       }


Output

Enter principle(Amount) = 1200
Enter Time = 2
Enter Rate = 5.4
Simple Interest = 129.60

C Program to Enter Marks of Five Subjects and calculate Total, Average and Percentage ?


Q:- Write a C Program to Enter Marks of Five Subjects and Calculate Total, Average and  
        Percentage ?
Input

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
float eng,phy,che,math,comp;
float total,average,percentage;
clrscr();
printf("Enter Marks of Five Subjects=");
scanf("%f%f%f%f%f",&eng,&phy,&che,&math,&comp);
total = eng+phy+che+math+comp;
average = total/5.0;
percentage =  (total/500.0)*100;
printf("Total Marks =%.2f",total);
printf("Average Marks =%.2f",average);
printf("Percentage =%.2f",percentage);
getch();
       }


Output

Enter Marks of Five Subjects =
95
76
85
90
89
Total Marks = 435.00
Average Marks = 87.00
Percentage = 87.00%

C Program to calculate Area of an Equilateral Triangle ?


Q:- Write a C Program to Calculate Area of an Equilateral Triangle ?

Input

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
float side,area;
clrscr();
printf(“Enter Side of an Equilateral Triangle=”);
scanf(“%f”,&side);
area = (sqrt(3)/(4))*(side*side);
printf(“Area of an Equilateral Triangle=%.3f”,area);
getch();
       }


Output

Enter Side of an Equilateral Triangle = 75
Area of an Equilateral Triangle = 2435.69 sq. units

C Program to Enter Base and Height of a Triangle and Find its Area ?


Q:- Write a C Program to Enter Base and Height of Triangle and Find its Area ?
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
float base,height,area;
clrscr();
printf(“Enter Base of Triangle=”);
scanf(“%f”,&base);
printf(“Enter Height of Triangle=”);
scanf(“%f”,&height);
area=(base*height)/2;
printf(“Area of Triangle=%.2f”,area);
getch();
}


Output

Enter Base of Triangle = 10
Enter Height of Triangle = 15
Area of triangle = 75.00 sq. units

C Program to Enter Two Angles of a Triangle and Find the Third Angle ?


Q:- Write a C Program to Enter Two Angles of a Triangle and Find the Third Angle ?
#include<stdio.h>
#include<conio.h>
int main()
{
int a1,a2,a3;
clrscr();
printf(“Enter Two Angles of Triangle=”);
scanf(“%d%d”,&a1,&a2);
a3=180-(a+b);
printf(“Third Angle of Triangle=%d”,a3);
getch();
}


Output
Enter Two Angles of Triangle = 60 30
Third Angle of Triangle = 90

C Program to Enter any Number and Calculate its Square Root ?


Q:- Write a C Program Enter any Number and Calculate its Square Root ?
Input
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
float num,result;
clrscr();
printf(“Enter a  Number=”);
scanf(“%f”,&num);
result=sqrt(num);
printf(“Square Root of %f=%.2f”,num,result);
getch();
}



Output

Enter a Number = 144
Square Root of 144.00 = 12.00

C Program to Find Power of any Number X^Y ?


Q:- Write a C Program to Find Power of any Number X^Y ?
Input
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int base,expo,power;
clrscr();
printf(“Enter a Base=”);
scanf(“%d”,&base);
printf(“Enter a Exponent=”);
scanf(“%d”,&expo);
power=pow(base,expo);
printf(“%d^%d=%d”,base,expo,power);
getch();
}


Output

Enter a Base = 5
Enter a Exponent = 3
5^3 = 125

C Program to Enter Temperature in Celcius and Convert it into Fahrenheit ?


Q:- Write a C Program Enter Temperature in Celcius and Convert it into Fahrenheit ?
Input
#include<stdio.h>
#include<conio.h>
int main()
{
float celcius,fahrenheit;
clrscr();
printf(“Enter Temperature in Celcius=”);
scanf(“%f”,&celcius);
fahrenheit=celcius*9/5+32;
printf(“Temperature in Fahrenheit=%.3f”,fahrenheit);
getch();
}


Output

Enter Temperature in Celcius = 100
Temperature in Fahrenheit = 212.00 Fahrenheit

C Program to Enter Length in Centimeter and Convert it into Meter and Kilometer ?


Q:- Write a C Program to Enter Length in Centimeter and it into Meter and Kilometer ?
 Input
#include<stdio.h>
#include<conio.h>
int main()
{
float m,cm,km;
printf(“Enter Length in Centimeter=”);
scanf(“%f”,cm);
m=cm /100.0;
km=cm /100000.0;
printf(“Length in Meter=%.2f\n”m);
printf(“Length in Kilometer=%.2f\n”,km);
getch();
}

Output
Enter Length in Centimeter = 1000
Length in Meter = 10.00 m
Length in Kilometer = 0.01 km

C Program to Enter Radius of a Circle and Find its Diameter, Circumference and Area ?


Q:-  Write a C Program to Enter Radius of a Circle and Find its Diameter, Circumference and            Area ?

Input
#include<stdio.h>
#include<conio.h>
int main()
{
float  radius,dia,circum,area;
clrscr();
printf(“Enter Radius of Circle=”);
scanf(“%f”,&radius);
dia=2*radius;
circum=2*3.14*radius;                    // Ï€=22/7=3.14
area=3.14*radius*radius;
printf(“Diameter of Circle=%.2f\n”,dia);
printf(“Circumference of Circle=%.2f\n”,circum);
printf(“Area of Circle=%.2f\n”,area);
getch();
}


Output
Enter Radius of Circle = 10
Diameter of Circle = 20.00 units
Circumference of Circle = 62.79.00 units
Area of Circle = 314.00 sq. units

C Program to Enter Length and Breadth of rectangle and Find its Area ?

Q:- Write a C Program to Enter Length and Breadth of Rectangle and Find its Area ?

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

int main()
    {
         float len,bre,area;
         clrscr();
         printf("Enter Length of Rectangle=");
         scanf("%f",&len);
         printf("Enter Breadth of rectangle=");
         scanf("%f",&bre);
  area=(len*bre);
  printf("Area of rectangle=%.2f",area);
  getch();
}


Output
Enter Length of rectangle = 10
Enter breadth of rectangle = 20
Area of Rectangle = 20.00 sq. Units 

C Program to Enter Length and Breadth of Rectangle and Find its Perimeter ?

Q:- Write a C Program to Enter Length and Breadth of Rectangle and Find its Perimeter ?

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

int main()
    {
         float len,bre,per;
         clrscr();
         printf("Enter Length of Rectangle=");
         scanf("%f",&len);
         printf("Enter Breadth of rectangle=");
         scanf("%f",&bre);
  per=2*(len+bre);
  printf("Perimeter of rectangle=%.2f",per);
  getch();
}


Output
Enter Length of rectangle = 10
Enter breadth of rectangle = 20
Perimeter of Rectangle = 60 

C Program to Enter two Numbers and Perform All Arithmetic Operations ?

Q:- Write a C Program to Enter Two Numbers and Perform all Arithmetic Operations ?

 Input
#include<stdio.h>
#include<conio.h>
int main()
    {
         int num1,num2;
         int sum,sub,mult;
         float div;
         clrscr();
         printf("Enter Two Numbers=");
         scanf("%d%d",&a,&b);
  sum=num1+num2;
  sub=num1-num2;
  mult=num1*num2;
  div=num1/num2;
  printf("Sum=%d",sum);
  printf("Difference=%d",sub);
  printf("Product=%d",pro);
  printf("Quotient=%.2f",pro);
  getch();
}


Output
Enter Two Numbers=20 10
Sum = 30
Difference = 10
Product = 200
Quotient = 2.00

C Program to Enter two Numbers and Find their Sum ?

Q:- Write a C Program to Enter Two Numbers and Find their Sum ?

 Input
#include<stdio.h>
#include<conio.h>
int main()
    {
         int num1,num2,sum;
         clrscr();
         printf(“Enter First Number=”);
         scanf(“%d”,&num1);
  printf(“Enter Second Number=”);
  scanf(“%d”,&num2);
  sum=num1+num2;
  printf(“Sum of %d and %d=%d”,num1,num2,sum);
  getch();
}


Output

Enter First Number=12
Enter Second Number=13
Sum of 12 and 13=25