Name Uzma Ashiq Reg 1441 - 320001
Name Uzma Ashiq Reg 1441 - 320001
Reg 1441_320001
Q3. Get input of your name, address, age in years, weight and height from
keyboard and display the information using unformatted I/O (String I/O).
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
main ()
int age=0;
printf("\nEnter name....");
gets(sname);
printf("enter address.....");
gets(addr);
printf("\nEntere age....");
scanf("%d",age);
printf("\nEnter weight....");
scanf("%d",&wt);
printf("\nEnter height....");
scanf("%d",&ht);
itoa(age,sage,10);
sprintf(swt,"%-2f",wt);
sprintf(sht,"%-2f",ht);
puts("\n");
puts(sname);
puts(addr);
puts(sage);
puts(swt);
puts(sht);
Output:
Enter address…..islamabad
Enter age….18
Enter weight….43
Enter height….5
#include <stdlib.h>
#include<conio.h>
int main()
{
int i=2;
printf("%d",i);
i=i+2; printf("%d",i);
i=i+2; printf("%d",i);
i=i+2; printf("%d",i);
i=i+2; printf("%d",i);
return 0;
}
Result :
2 4 6 8 10
Q5. Pounds to Kilograms
One pound is equivalent to 0.454 kilograms. Write a program that asks the user to
enter the mass of an object in pounds and then calculates and displays the mass
of the object in kilograms.
ONE_POUND_IN_KILOGRAMS = .454
RESULT
Enter mass of an object: 5
Q7. Write a program that asks the user to enter the number of times that they
have run around a racetrack, and then uses a loop to prompt them to enter the
lap time for each of their laps. When the loop finishes, the program should display
the time of their fastest lap, the time of their slowest lap, and their average lap
time.
lap_time = []
#Split string on whitespace, convert each string to float and save to laptime string
lap_time.append(float(item))
fastest = min(lap_time)
slowest = max(lap_time)
average = sum(lap_time)/len(lap_time)
RESULT
Enter the lap times separated by space1.0 2.0 3.0 4.0 5.0
Fastest 1.0
Slowest 5.0
Average 3.0