You are on page 1of 11

Medi Caps University

PSP Practical Assignment no. 3 Submitted by – Hatim Patwa

Q1// WAP to find out the input number is divisible by 7 or not?


Syntax
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int num;
printf("Enter a number to check its Divisiblity by 7 : ");
scanf("%d", &num);
if ((num % 7) == 0)
printf("The number %d is divisible by 7",num);
else
printf("The number %d is not divisible by 7",num);
return 0;
}
_______________________________________________________________________________________
Q2//WAP to find out the maximum number between two numbers.
Syntax
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
int a, b;
system("cls");
printf("Enter two numbers to find out maximum : ");
scanf("%d %d", &a, &b);
if (a > b)
printf("%d is greater than %d", a, b);
else if (b > a)
printf("%d is greater than %d", b, a);
else if (a == b)
printf("Both are equal");
return 0;
}
_______________________________________________________________________________________
Q3//WAP to find out the maximum number between three numbers.
Syntax
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int a, b, c;
printf("Enter three numbers to find out maximum : ");
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c)
printf("%d is the Greatest Number", a);
else if (b > a && b > c)
printf("%d is the Greatest Number", b);
else if (c > b && c > a)
printf("%d is the Greatest Number", c);
return 0;
}

_______________________________________________________________________________________
Q4//WAP to find out the minimum number between two numbers.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
int a, b;
system("cls");
printf("Enter two numbers to find out minimum : ");
scanf("%d %d", &a, &b);
if (a < b)
printf("%d is the minimum", a);
else if (b < a)
printf("%d is the minimum", b);
else if (a == b)
printf("Both are equal");
return 0;
}
_______________________________________________________________________________________
Q5// WAP to find out the minimum number between three numbers.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int a, b, c;
printf("Enter three numbers to find out minimum : ");
scanf("%d %d %d", &a, &b, &c);
if (a < b && a < c)
printf("\n\n%d is the Smallest Number", a);
else if (b < a && b < c)
printf("\n\n%d is the Smallestt Number", b);
else if (c < b && c < a)
printf("\n\n%d is the Smallest Number", c);
return 0;
}
_______________________________________________________________________________________
Q6//WAP to input two numbers and to find out whether they are equal or not.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int a, b;
printf("Enter two numbers to check its Equality : ");
scanf("%d %d", &a, &b);
if (a == b)
printf("\n\nBoth number are equal ");
else
printf("\n\nBoth number are not equal ");
return 0;
}
_______________________________________________________________________________________
Q7//WAP to find out the input number is divisible by 2, 3, 5, 7, and 9 or not.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int num, sum;
printf("Enter a number for the Divisiblity Test : ");
scanf("%d", &num);
if ((num % 2 == 0) && (num % 3 == 0) && (num % 5 == 0) && (num % 7 == 0)
&& (num % 9 == 0))
printf("\n\nThe number is divisible by 2,3,5,7 and 9");
else
printf("\n\nThe number is not divisble by 2,3,5,7 and 9");
return 0;
}
_______________________________________________________________________________________
Q8// Any character is entered through key keyboard, WAP using conditional operator to determine
whether the Character entered is a small case alphabet or not.
Special symbol or not. */
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
char inp;
printf("Enter any character or special symbol : ");
scanf("%c", &inp);
printf("%d\n\n\n", inp);
(inp >= 97 && inp <= 122) ? printf("\nCharacter entered is a small case
alphabet") : printf("\nCharacter entered is not a small case alphabet");

((inp >= 32 && inp <= 47) || (inp >= 58 && inp <= 64) || (inp >= 91 && inp
<= 96) || (inp >= 123 && inp <= 126)) ? printf("\nCharacter entered is special
symbol") : printf("\nCharacter
entered is not a special symbol");
return 0;
}
_______________________________________________________________________________________
Q9// Any year is input through the keyboard. WAP to determine whether the year is leap year or not.
(Using conditional operator)
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int year;
printf("Enter the year to find wether its leap year or not : ");
scanf("%d", &year);
((year % 4) == 0) ? printf("\n\n%d is a leap year", year) : printf("\n\n%d
is not a leap year",year);
getch();
return 0;
}
_______________________________________________________________________________________
Q10// Any year is input through the keyboard. WAP to determine whether the year is leap year or not.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int year;
printf("Enter the year to find wether its leap year or not : ");
scanf("%d", &year);
if ((year % 4) == 0)
printf("\n\n%d is a leap year", year);
else
printf("\n\n%d is not a leap year", year);
return 0;
}
Q11// Any integer is input through the keyboard. WAP to find out whether it is an odd number of even
number.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int a;
printf("Enter a number to check wether its even or odd : ");
scanf("%d", &a);
if (a % 2 == 0)
printf("\n\n%d is an even number", a);
else
printf("\n\n%d is a odd number", a);
return 0;
}
Q12// WAP while purchasing certain items, a discount of 10% is offered if the quantity purchased is
more than 1000. If quantity and price per item are input through the keyboard, then to calculate the
total expenses.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int q, p, sum, num, total, i;
sum = 0;
total = 0;
printf("Enter number of items bought : ");
scanf("%d", &num);
if (num >= 1)
{
for (i = 1; i <= num; i++)
{
printf("\n\n\nItem %d", i);
printf("\nEnter Quantity : ");
scanf("%d", &q);
printf("Enter Price : ");
scanf("%d", &p);
sum = q * p;
total = total + sum;
}
int dis = total * 0.1;
int amt1 = total - dis;
if (total > 1000)
printf("The Order Total is %d", amt1);
else
printf("The Order Total is %d", total);
}
else
printf("Wrong entry");
return 0;
}
_______________________________________________________________________________________
Q13// The current year and the year in which the employee joined the organization are entered through
the keyboard.
If the number of years for which the employee has served the organization is
greater than 3 then a bonus of Rs. 2500/- is given to the employee. If the years of service are not greater
than 3, then program should not do anything?
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int cy, jy;
printf("Enter Current Year : ");
scanf("%d", &cy);
printf("Enter Joining Year of the Employee : ");
scanf("%d", &jy);
if ((cy - jy) > 3)
printf("\n\nThe Employee has been given a bonus of RS 2500/- ");
else
_Exit(0);
return 0;
}
_______________________________________________________________________________________
Q14// In a company an employee is paid as under : If his basic salary is less than Rs. 1500, then HRA=10%
of basic salary and DA=90% of basic salary. If his salary is either equal to or above Rs. 1500, then
HRA=Rs. 500 and DA=98% of basic salary. If the employee’s salary is entered through the keyboard WAP
to find his gross Salary?
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
float bs;
printf("Enter Salary of the Employee : ");
scanf("%f", &bs);
if (bs < 1500)
{
float hra = bs * 0.1;
float da = 0.9 * bs;
float gs = bs + hra + da;
printf("\n\nThe Gross Salary of the employee is %.2f ", gs);
}
else if (bs >= 1500)
{
float da2 = 0.98 * bs;
float gs2 = bs + 500 + da2;
printf("\n\nThe Gross Salary of the employee is %.2f ", gs2);
}
return 0;
}
_______________________________________________________________________________________
Q15// If the cost price and selling price of an item is input through the keyboard, WAP to determine
whether the seller has made profit or incurred loss.Also determine how much profit he has made or loss
he incurred?
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
int cp, sp;
printf("Enter the Cost price of the Product : ");
scanf("%d", &cp);
printf("Enter the Selling price of the Product : ");
scanf("%d", &sp);
int pol = sp - cp;
if (pol > 0)
{
printf("\n\nThe Seller has made Profit");
printf("\nProfit = %d", pol);
}
else if (pol < 0)
{
printf("\n\nThe Seller has incurred a Loss");
printf("\nLoss = %d", pol);
}
else if(pol==0)
printf("\n\nThe Seller has incurred No Loss No Profit");
return 0;
}
_______________________________________________________________________________________
Q16// Any character is entered through the keyboard, WAP to determine whether the character entered
is a capital letter, a small case letter, a digit or special symbol.*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
char a;
printf("Enter Any Character : ");
scanf("%c", &a);
if ((a >= 32 && a <= 47) || (a >= 58 && a <= 64) || (a >= 91 && a <= 96)
|| (a >= 123 && a < 127))
printf("\n\n%c is a SPECIAL CHARACTER", a);
else if (a >= 48 && a <= 57)
printf("\n\n%c is a NUMBER", a);
else if (a >= 65 && a <= 90)
printf("\n\n%c is a CAPITAL LETTER", a);
else if (a >= 97 && a <= 122)
printf("\n\n%c is a SMALL CASE LETTER", a);
return 0;

You might also like