AWL C Programming
5 subscribers
1 photo
1 file
1 link
C Language - Solved Programs
Download Telegram
Channel created
2. WAP to Input 2 numbers and find the sum.
#include<stdio.h>
int main()
{
int a, b, c;
printf("Enter 1st Number: ");
scanf("%d",&a);
printf("Enter 2nd Number: ");
scanf("%d",&b);
c=a+b;
printf("Sum = %d",c);
return 0;
}
3. WAP to input two numbers and find multiplication


#include<stdio.h>
int main()
{
int a, b, c;
printf("Enter 1st number");
scanf("%d",&a);
printf("Enter 2nd number");
scanf("%d",&b);
c=a*b;
printf("Multiplication = %d",c);
return 0;
}
4. WAP to Input number and calculate its square and cube.


#include<stdio.h>
int main()
{
int n, sq, cube;
printf("Enter Number:");
scanf("%d",&n);
sq = n * n;
cube = n * n * n;
printf("Square = %d",sq);
printf("Cube = %d",cube);
return 0;
}
5. WAP to input radius and calculate area of circle and circumference of a circle. Area of circle = 3.14*r*r, Circumference of circle = 2*3.14*r.


#include<stdio.h>
int main()
{
float r, a, c;
printf("Enter radius:");
scanf("%f", &r);
a=3.14*r*r;
printf("Area of circle = %f\n", a);
c = 2*3.14*r;
printf("Circumference of circle = %f\n", c);
return 0;
}
6. WAP to input length and breadth of a rectangle and calculate its area. Area=Length*Breadth.


#include<stdio.h>
int main()
{
int a, l, b;
printf("Enter length:");
scanf("%d",&l);
printf("Enter breadth:");
scanf("%d",&b);
a=l*b;
printf("Area = %d",a);
return 0;
}
7. WAP to input radius and height of a cylinder and calculate volume of cylinder. Volume=3.14*r*r*h


#include<stdio.h>
int main()
{
float r, h, v;
printf("Enter Radius of a Cylinder:");
scanf("%f",&r);
printf("Enter Height of a Cylinder:");
scanf("%f",&h);
v = 3.14 * r * r * h;
printf("Volume of Cylinder = %f",v);
return 0;
}
8⃣ WAP to input principal, rate, time and calculate Simple Interest. Simple Interest=Principal*Rate*Time/100.


#include<stdio.h>
int main()
{
float p,r,t,si;
printf("Enter Principal, Rate, Time: ");
scanf("%f%f%f",&p,&r,&t);
si = p*r*t/100;
printf("Simple Interest = %f",si);
return 0;
}
9⃣ WAP to Input 5 subject marks of a student and find total marks and percentage obtained by the student.

#include<stdio.h>
int main()
{
int eng, hindi, maths, sci, computer, total;
float per;

printf("Enter English marks:");
scanf("%d",&eng);

printf("Enter Hindi marks:");
scanf("%d",&hindi);

printf("Enter Maths marks:");
scanf("%d",&maths);

printf("Enter Science marks:");
scanf("%d",&sci);

printf("Enter Computer marks:");
scanf("%d",&computer);

total = eng + hindi + maths + sci + computer;
per=total/5.0;

printf("Total = %d",total);
printf("\nPercentage = %f",per);
return 0;
}
🔟 WAP to convert temperature from Fahrenheit to Celsius. c=(f-32)*5/9

#include<stdio.h>
int main()
{
float c, f;
printf("Enter temperature in Fahrenheit: ");
scanf("%f",&f);
c=(f-32)*5/9;
printf("Temperature in Celsius = %.2f",c);
return 0;
}
Output
Enter temperature in Fahrenheit: 98.6
Temperature in Celsius = 37.00
1⃣1⃣ WAP to convert temperature from Celsius to Fahrenheit. f=c*9/5+32

#include<stdio.h>
int main()
{
float c, f;
printf("Enter temperature in Celicus:");
scanf("%f",&c);
f=c*9/5+32;
printf("Temperature in Fahrenheit = %.2f",f);
return 0;
}
Output
Enter temperature in Celicus: 37
Temperature in Fahrenheit = 98.60
👍1
12 WAP to Input two numbers and swap them.

#include<stdio.h>
int main()
{
int a, b, c;
printf("\nEnter two numbers:");
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
printf("A = %d\n",a);
printf("B = %d",b);
return 0;
}
Output:
Enter two numbers: 10
20
A = 20
B = 10
13 WAP to Input two numbers and swap them without using 3rd variable.

#include<stdio.h>
int main()
{
int a, b, c;
printf("\nEnter two numbers:");
scanf("%d%d",&a,&b);
b=a+b;
a=b-a;
b=b-a;
printf("A = %d\n",a);
printf("B = %d",b);
return 0;
}
Output:
Enter two numbers: 10
20
A = 20
B = 10
14. WAP to Input distance (in km) and convert in meter, centimeter, and inches.

#include<stdio.h>
int main()
{
float km, m, cm, in;
printf("Enter distance in KiloMeter:");
scanf("%f",&km);
m = km * 1000;
cm = m * 100;
in = cm/2.54;

printf("\nMeter = %.2f",m);
printf("\nCentimeter = %.2f",cm);
printf("\nInches = %.2f",in);
return 0;
}
Output:
Enter distance in KiloMeter:1
Meter = 1000.00
Centimeter = 100000.00
Inches = 39370.10
Q15. WAP to Input minutes and convert in hours and minutes.

#include<stdio.h>
int main()
{
int h, m, t;
printf("Enter time in minutes:");
scanf("%d",&t);
h=t/60;
m=t%60;
printf("Hours = %d",h);
printf(" Minutes = %d",m);
return 0;
}
Output:
Enter time in minutes:200
Hours = 3
Minutes = 20
Q16. WAP to convert total number of days into years, months, weeks, and days.

#include<stdio.h>
int main()
{
int d, y, m, w;
printf("\nEnter total number of Days: ");
scanf("%d",&d);
y = d/365;
d = d%365;
m = d/30;
d = d%30;
w = d/7;
d = d%7;
printf("\nYears = %d",y);
printf("\nMonths = %d",m);
printf("\nWeeks = %d",w);
printf("\nDays = %d",d);
return 0;
}
Output:
Enter total number of Days: 1050
Years = 2
Months = 10
Weeks = 2
Days = 6
👍1