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

WAP To Print Sum of Two Numbers

The document contains the code for several C programs that take user input and perform calculations. The programs include: 1) Calculating the sum of two numbers 2) Calculating the area of a rectangle 3) Calculating simple interest 4) Calculating the average of three numbers 5) Calculating the volume of a cylinder 6) Checking if a number is odd or even 7) Converting days into years, months, days 8) Checking if a user is eligible to vote Each program uses basic input/output functions and mathematical operators to perform its calculation and display the output.

Uploaded by

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

WAP To Print Sum of Two Numbers

The document contains the code for several C programs that take user input and perform calculations. The programs include: 1) Calculating the sum of two numbers 2) Calculating the area of a rectangle 3) Calculating simple interest 4) Calculating the average of three numbers 5) Calculating the volume of a cylinder 6) Checking if a number is odd or even 7) Converting days into years, months, days 8) Checking if a user is eligible to vote Each program uses basic input/output functions and mathematical operators to perform its calculation and display the output.

Uploaded by

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

WAP to print sum of two numbers:

/*program to sum 2 numbers */


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter the first number");
scanf("%d",&a);
printf("Enter the second number");
scanf("%d",&b);
c = a+b;
printf("sum = %d",c);
getch();
}

WAP to calculate the area of a rectangle in c. [Hints: a = l x b]


#include<stdio.h>
#include<conio.h>
void main()
{
int l, b, a;
printf (“Enter Length: ”);
scanf (“%d”, &l);
printf (“Enter Breadth: “);
scanf (“%d”, &b);
a = l * b;
printf (“The area is %d”, a);
getch();
}

WAP to calculate the simple interest in c. [Hints: i= (ptr)/100]


#include<stdio.h>
#include<conio.h>
int main()
{
float p, t, r, i;
printf (“Enter principal time and rate: ”);
scanf (“%f %f %f”, &p, &t, &r);
i= (p*t*r)/100;
printf (“The interest is %f”, i);
return 0;
}
WAP to calculate the average of 3 number in c. [Hints: av= (a+b+c)/3]
#include<stdio.h>
#include<conio.h>
int main()
{
float a, b, c, av;
printf (“Enter 3 numbers: ”);
scanf (“%f %f %f”, &a, &b, &rc);
av= (a+b+c)/3;
printf (“The average is %f”, av);
return 0;
}

WAP to calculate the volume of cylinder in c. [Hints: v= pi*r*r*h]


#include<stdio.h>
#include<conio.h>
int main()
{
float pi=3.14, r, h, v;
printf (“Enter radius and height: ”);
scanf (“%f %f ”, &r, &h);
v= pi*r*r*h;
printf (“The volume is %f”, v);
return 0;
}

Write a program to check whether given number is odd or even

int main()
{
int n, r ;
printf (“Enter number”);
scanf (“%d”, &n); Qbasci = MOD
r = n%2; c=%
if (r ==0)
{
printf (“%d is even", n);
}
else
{
printf (“%d is odd", n);
}
return 0;
}

WAP to convert days into respective years, months and days.

int main()
{
int days, y, m,d, rd;
printf (“Enter days”);
scanf (“%d”, &days);
y = days/365;
rd = days%365;
m = rd/30;
d = rd%30;
printf (“Year = %d Month = %d Day = %d", y, m, d);
return 0;
}

WAP to print you are eligible to vote or not:

You might also like