Professional Documents
Culture Documents
pasdfghjklzxcvbnmqwertyuiopasdfghjkl
zxcvbnmqwertyuiopasdfghjklzxcvbnmq
wertyuiopasdfghjklzxcvbnmqwertyuiop
Assignment 5
asdfghjklzxcvbnmqwertyuiopasdfghjklzx
NAME: Jeet Ariwala
cvbnmqwertyuiopasdfghjklzxcvbnmqwe
Rollno.: A-69
rtyuiopasdfghjklzxcvbnmqwertyuiopasd
fghjklzxcvbnmqwertyuiopasdfghjklzxcvb
nmqwertyuiopasdfghjklzxcvbnmqwerty
uiopasdfghjklzxcvbnmqwertyuiopasdfgh
jklzxcvbnmqwertyuiopasdfghjklzxcvbnm
qwertyuiopasdfghjklzxcvbnmqwertyuio
pasdfghjklzxcvbnmqwertyuiopasdfghjkl
zxcvbnmrtyuiopasdfghjklzxcvbnmqwert
yuiopasdfghjklzxcvbnmqwertyuiopasdfg
hjklzxcvbnmqwertyuiopasdfghjklzxcvbn
mqwertyuiopasdfghjklzxcvbnmqwertyui
Q-1A function f is defined as follows
F(x) = ax3–bx2 + cx –d if x > k
=0 if x = k
= - ax3 + bx2 –cx + d if x < k
Write a program to accept a, b, c, d, k and x. and display
the value of f(x).
Source Code:
#include<math.h>
#include<stdio.h>
intmain()
{
inta,b,c,d,k,x,ans;
printf("Enter value of a:");
scanf("%d",&a);
printf("\nEnter value of b:");
scanf("%d",&b);
printf("\nEnter value of c:");
scanf("%d",&c);
printf("\nEnter value of d:");
scanf("%d",&d);
printf("\nEnter value of k:");
scanf("%d",&k);
printf("\nEnter value of x:");
scanf("%d",&x);
if(x>k)
{
printf("\nFunction f(x)=ax^3-bx^2+cx-d");
ans=((a*x*x*x)-(b*x*x)+(c*x)-d);
printf("\nValue of f(x):%d",ans);
}
else if(x<k)
{
printf("\nFunction f(x)=-ax^3+bx^2-cx+d");
ans=((-(a*x*x*x))+(b*x*x)-(c*x)+d);
printf("\nValue of f(x):%d",ans);
}
else
{
printf("\nValue of f(x): 0");
}
Output:
Program:
#include<stdio.h>
intmain()
{
int a;
printf("ENTER YOUR MARKS OUT OF 100:");
scanf("%d",&a);
if(a>=80)
{
printf("Your grade is Distinction.");
}
else if(a>=60)
{
printf("Your grade is First Class.");
}
else if(a>=35)
{
printf("Your grade is Second Class.");
}
else
{
printf("You are fail");
}
}
Output:
Program:
#include<stdio.h>
intmain()
{
float a,b,x;
intans;
printf("Enter value of a:");
scanf("%f",&a);
printf("\nEnter value of b:");
scanf("%f",&b);
x=(a/b);
ans=int(x);
printf("\nResult is:%d",ans);
}
Output:
Program:
#include<stdio.h>
intmain()
{
float b,x;
inta,ans;
printf("Enter value of a:"); //negative integer
scanf("%d",&a);
printf("\nEnter value of b:"); //positive float
scanf("%f",&b);
x=(a/b);
ans=int(x);
printf("\nResult is:%d",ans);
}
Output:
#include<stdio.h>
intmain()
{ float a,c;
int b;
printf("enter the value of a : "); //positive float
scanf("%f",&a);
printf("enter the value of b : "); //negative integer
scanf("%d",&b);
c= a/b;
printf("ANS IS %f",c); //float number
return 0;
}
Output:
Q-4A cloth showroom has announced the following
seasonal discount on the purchase of items.
Purchase Discount
Amount
Mill Cloth Handloom Items
0 –100 - 5.0 %
101 –200 5.0 % 7.5%
#include<stdio.h>
intmain()
{
float a,b,m,h;
printf("enter the value of m : ");
scanf("%f",&m);
printf("enter the value of h : ");
scanf("%f",&h);
a=m+h;
if (a>300)
{
b=m-(m/10)+h-(h*15/100);
printf("YOUR NET BILL IS %f",b);
}
else if (a>200)
{
b=m-(m*7.5/100)+h-(h*10/100);
printf("YOUR NET BILL IS %f",b);
}
else if (a>100)
{
b=m-(m*5/100)+h-(h*7.5/100);
printf("YOUR NET BILL IS %f",b);
}
else
{
b=m-(m*0/100)+h-(h*5/100);
printf("YOUR NET BILL IS %f",b);
}
return 0;
}
Output:
Program:
#include<stdio.h>
intmain()
{ //c is the amount of commission
float x,c; //x is amount of insuarance
printf("enter the value of x: ");
scanf("%f",&x);
if (x>=25000)
{
c=((x-25000)*0.75/100)+140;
printf("THE COMMISSION IS %.2f",c);
}
else if (x>=10000)
{
c=(x*0.6/100)+50;
printf("the commission is %.2f",c);
}
else
{
c=(x*0.5/100);
printf("YOUR COMMISION IS %.2f",c);
}
return 0;
}
Output: