ARSHIA ZAIN
MBA(in marketing)
HOME TUTOR
Q1) print your name in the console.
#include<stdio.h>
main()
//print your name
printf("Arshia Zain");
}
Q2) Take radius as an input from user in centimeter and calculate the volume of sphere in
centimeter-cube (cm^3) and also in meter-cube (m^3).
Hint: V = (4/3) * pi * r^3 1cm = 0.01m
#include<stdio.h>
#include<math.h>
main()
float vol;
float radius;
float temp;
float vol1;
printf("enter radius in centimeter");
scanf("%f", & radius);
temp = pow (radius , 3);
vol = (4.0/3.0) * 3.142 * temp;
printf("volume in centimeter cube is %f \n", vol);
vol1 = 0.0001*vol;
printf("enter centimeter cube into metercube %f ", vol );
}
Q3)Take diameter as an input from user in centimeter and write a program to calculate the area
of a circle in meter-square(m^2).
hint : r = d/2 A = pi * r^2
#include<stdio.h>
#include<math.h>
main()
float dia, area, radius, pwr, area_m2;
printf("enter, diameter");
scanf("%f", &dia);
radius= dia/2.0;
pwr=pow(radius,2);
area=3.142* pwr;
printf ("the area of circle in cm2= %f n " , area);
area_m2 = area *0.0001;
printf ("the area of circle in m2 = %f", area_m2);
}
Q4)Take a value of an angle in degree measure from user and convert it into radian measure.
Also calculate the slope of that angle in radian measure.
Hint: 1 rad = deg * pi / 180 m = tan(angle) // m is the slope
#include<stdio.h>
#include<math.h>
main()
{
float rad,slope,deg;
printf("value of an angle in deg");
scanf("%f" , & deg);
printf("value of an angle in deg %f \n" , deg);
// the slope of that angle in rad measure
rad=deg*3.412/180;
printf("angle in rad %f \n" , rad);
slope= tan (deg);
printf("slope in degree %f" , slope);
}
Q5) Take two coordinates from user and print the values in such format
“1st coordinate = (x1, y1)
2nd coordinate = (x2,y2)”
Also find the distance between two coordinates.
___________________
Hint: d =_/(x2-X1)^2 + (y2-y1)^2
#include<stdio.h>
#include<math.h>
main()
//distance between them
// _________________________
// _/ (x1-x2)^2+(y1-y2)^2
float x1, x2, y1, y2;
float x = pow(x1-x2, 2);
float y = pow(y1-y2, 2);
// _________
// _/ x+y
float ans;
ans = sqrt(x+y);
printf("x, y");
}
Q6) Take an input from user and check if it is divisible by 2 or not?
#include<stdio.h>
main()
int num;
scanf("%d" , & num);
int rem;
rem = num%2;
if(rem == 0)
{
printf ("%d is divisible by 2" , num);
else
printf ("%d is not divisible by 2" , num);
}
Q7) Take an input from user and check if it is negative or positive?
#include<stdio.h>
main()
int num;
scanf("%d" , & num);
if(0>num)
printf ("%d is negative" , num);
else
printf("%d is positive" , num);
}
Q8) take obtained marks of 6 subjects (maths, phy, urdu, english, islamiat and computer), his
age as input from user and print the marksheet in such format also if percentage in greater than
or equal to 50 print “Pass” as remarks value otherwise fail:
--------------------------------------------------------------------------------------
Name: XYZ
Father Name: XYZ
Age:
Institute: Computer Collegiate
---------------------------------------------------------------------------------------
Maths value
Physics value
Urdu value
English value
Islamiat value
Computer value
-----------------------------------------------------------------------------------------
obtained marks value
total marks value
Percentage value
Remarks value
#include<stdio.h>
main()
// to input the marksheet of 6 subject
int maths, physics, urdu, english, islamiat, computer, tot_marks;
float obt_marks, per ;
printf ("--------------------------------------------------\n\n");
printf("Arshia zain \n");
printf("Zain ul abideen \n");
printf("24 \n");
printf("Computer collegiate \n");
printf ("---------------------------------------------------- \n\n");
printf("maths :");
scanf("%d" , &maths);
printf("physics :");
scanf("%d" , &physics);
printf("urdu :");
scanf("%d" , &urdu);
printf("english :");
scanf("%d" , &english);
printf("islamiat :");
scanf("%d" , &islamiat);
printf("computer :");
scanf("%d" , &computer);
printf("----------------------------------------------------------------------------------------------------------------------------
----\n");
obt_marks = maths+physics+urdu+english+islamiat+computer;
printf("obt_marks :%f \n" , obt_marks);
tot_marks = 600;
printf("tot_marks :600 \n");
per = (obt_marks/tot_marks)*100;
printf("percentage %f \n" , per);
if (per>50)
printf("pass");
else
printf("fail");