0% found this document useful (0 votes)
13 views3 pages

Lab2 PES1UG24CS579

The document contains multiple C programming code snippets that perform various arithmetic and conversion tasks, such as calculating sums, averages, distances, volumes, simple interest, and temperature conversions. Each code snippet includes prompts for user input and prints the results. There are several syntax errors in the code, including incorrect variable types and missing semicolons.

Uploaded by

zahoorm0712
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)
13 views3 pages

Lab2 PES1UG24CS579

The document contains multiple C programming code snippets that perform various arithmetic and conversion tasks, such as calculating sums, averages, distances, volumes, simple interest, and temperature conversions. Each code snippet includes prompts for user input and prints the results. There are several syntax errors in the code, including incorrect variable types and missing semicolons.

Uploaded by

zahoorm0712
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

QUESTION 1:

#include <stdio.h>
int main(){
int a,b;
oat sum,avg;
printf("Enter the two numbers");
scanf("%d %d" , &a,&b);
sum = a+b
avg = sum/2
printf("The sum of two numbers %d and %d is %f",a,b,sum);
printf("The avg of two numbers %d and %d is %f",a,b,avg):
return 0;
}

QUESTION 3:
#include <stdio.h>
int main(){
int a,b,c;
printf("Enter the distance in km");
scanf("%d",&a);
b = a*1000;
c = b*100;
printf("The distance can be expressed as %d m , %d cm", b,c);
return 0;
}

QUESTION 5:
#include <stdio.h>
int main(){
int r,h;
oat v;
printf("Enter the radius of the base: ");
scanf("%d",&r);
printf("Enter the height: \n");
scanf("%d" , &h);
v = 3.14*r*r*h;
printf("The volume of the cylinder is: %f \n",v);
return 0;
}

QUESTION 6:
#include <stdio.h>
int main(){
int a,b,r;
oat q;
printf("Enter the dividend and the divisor \n");
scanf("%d %d" , &a,&b);
q = a/b;
r = a%b;
printf("The quotient is %f and the remainder is %d \n",q,r);
return 0;
}
fl
fl
fl
QUESTION 7:
#include <stdio.h>
int main(){
int a,b;
printf("Enter the number \n");
scanf("%d",&a);
b = a%10;
printf("The last digit of the given number is:%d \n");
return 0;
}

QUESTION 8:
#include <stdio.h>
int main(){
int a,b,c;
oat i;
printf("Enter the Principle Amount,rate in percentage,time in years \n");
scanf("%d %d %d" , &a,&b,&c);
i = a*b*c/100;
printf("The simple interest is: %f \n",i);
return 0;
}

QUESTION 9:
#include <stdio.h>
int main(){
int a,b;
oat t;
printf("Enter the initial number of bacteria and total number of hours\n");
scanf("%d %d" , &a,&b);
t = a*b*b;
printf("The total bacteria count after %d hours is:%f \n",b,t);
return 0;
}

QUESTION 11:
#include <stdio.h>
int main(){
oat a,b;
printf("Enter the temperature in degree Celsius \n");
scanf("%f" , &a);
b = 1.8*a + 32;
printf("The temperature in Fahrenheit is: %f \n",b);
return 0;
}

QUESTION 13:
#include <stdio.h>
int main(){
int a,b,c,d;
printf("Enter the three digit number:");
scanf("%d",&a);
fl
fl
fl
b = a%10;
c = (a%100-b)/10;
d = (a%1000-b-c)/100;
printf("The output is: %d , %d , %d \n", b,c,d);
return 0;
}

You might also like