0% found this document useful (0 votes)
35 views8 pages

CP Lab Report 14-05-23

The document contains 20 coding problems involving basic input/output operations and mathematical calculations in C language. Each problem contains the code to read input values, perform calculations, and print output. The problems cover a range of topics including calculating areas, sums, averages, distances, converting between time units and more. The code samples provide solutions to common introductory programming exercises.
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)
35 views8 pages

CP Lab Report 14-05-23

The document contains 20 coding problems involving basic input/output operations and mathematical calculations in C language. Each problem contains the code to read input values, perform calculations, and print output. The problems cover a range of topics including calculating areas, sums, averages, distances, converting between time units and more. The code samples provide solutions to common introductory programming exercises.
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/ 8

Problem-1001

#include <stdio.h>

int main() {

printf("Hello World!\n");
return 0;
}

OUTPUT

Problem-1002

#include<stdio.h>
int main()
{
double R,A;
scanf("%lf", &R);
A = 3.14159 * R * R;
printf("A=%.4lf\n", A);
return 0;
}

OUTPUT

Problem- 1003
#include <stdio.h>

int main() {
int a;
int b;
scanf("%d",&a);
scanf("%d",&b);

printf("SOMA = %d\n", a+b);

return 0;
}

OUTPUT
Problem-1004
#include<stdio.h>
int main(){
int i,j;
scanf("%d%d",&i,&j);

printf("PROD = %d\n",i*j);

return 0;
}

OUTPUT

Problem- 1005
#include<stdio.h>
int main(){
double A, B, m;
scanf("%d\n%d", &A, &B);
m= (3.5*A + 7.5*B)/11.0;
printf("MEDIA = %d\n",m);
return 0;
}
OUTPUT

Problem-1006
#include<stdio.h>
int main(){
double A, B, C, med;

scanf("%lf\n%lf\n%lf", &A, &B, &C);


med= (2*A + 3*B + 5*C)/10.0;
printf("MEDIA = %.1lf\n",med);

return 0;
}
OUTPUT
Problem-1007
#include<stdio.h>
int main(){

int A, B, C, D, Difference;
scanf("%d\n%d\n%d\n%d", &A, &B, &C, &D);
Difference= A*B - C*D;

printf("DIFERENCA = %d\n", Difference);

return 0;
}
OUTPUT

Problem-1008
#include<stdio.h>
int main(){

int number, hours;


double value, salary;
scanf("%d\n%d\n %lf", &number, &hours, &value);
salary = hours * value;
printf("NUMBER = %d\nSALARY = U$ %.2lf\n",number,salary);

return 0;
}
OUTPUT

Problem-1009
#include<stdio.h>
int main(){
char smName[10];
double salary, sold, total;
scanf("%s\n%lf\n%lf",&smName, &salary,&sold);
total= salary+0.15*sold;

printf("TOTAL = R$ %.2lf\n", total);

return 0;
}
OUTPUT
Problem-1010
#include<stdio.h>
int main(){

int code1, quantity1, code2, quantity2;


double value1, value2, value;
scanf("%d %d %lf",&code1, &quantity1, &value1);
scanf("%d %d %lf",&code2, &quantity2, &value2);

value = quantity1*value1 + quantity2*value2;


printf("VALOR A PAGAR: R$ %.2lf\n", value);
return 0;
}
OUTPUT

Problem-1011
#include<stdio.h>
int main(){

int R;
double volume;
const double PI= 3.14159;

scanf("%d", &R);
volume = 4.0/3.0*PI*R*R*R;
printf("VOLUME = %.3lf\n", volume);

return 0;
}
OUTPUT
Problem-1012
#include<stdio.h>
int main(){

double A, B, C;
const double PI= 3.14159;
scanf("%lf\n%lf\n%lf",&A, &B, &C);

printf("TRIANGULO: %.3lf\n",(A*C)/2.0);
printf("CIRCULO: %.3lf\n",PI*C*C);
printf("TRAPEZIO: %.3lf\n",(A+B)/2.0*C);
printf("QUADRADO: %.3lf\n",B*B);
printf("RETANGULO: %.3lf\n",A*B);

return 0;
}
OUTPUT

Problem-1013
#include<stdio.h>
#include<math.h>

int main(){
int a, b, c, response;

scanf("%d\n%d\n%d", &a, &b, &c);


response = (a+b+abs(a-b))/2;
response = (response+c+abs(response-c))/2;
printf("%d eh o maior\n", response);

return 0;
}
OUTPUT

Problem-1014
#include<stdio.h>
#include<math.h>

int main(){
int a;
float b;
scanf("%d\n%f", &a, &b);
printf("%.3f km/l\n", (float)a/b);
return 0;
}
OUTPUT

Problem-1015
#include<stdio.h>
#include<math.h>

int main(){

float x1, x2, y1, y2, a;


scanf("%f\n%f\n%f\n%f", &x1,&y1,&x2,&y2);
a = sqrt(pow((x2-x1),2)+pow((y2-y1),2));
printf("%.4f\n", a);
return 0;
}
OUTPUT

Problem-1016
#include<stdio.h>
#include<math.h>

int main(){

int d;
scanf("%d", &d);
printf("%d minutos\n", d*2);
return 0;
}
OUTPUT
Problem-1017
#include<stdio.h>
#include<math.h>

int main(){

int distance, force;


float fuel;
scanf("%d\n%d", &distance, &force);
fuel = (distance*force)/12.0;
printf("%.3f\n", fuel);

return 0;
}
OUTPUT

Problem-1018
#include<stdio.h>
#include<math.h>

int main(){
int bNote[7]={100, 50, 20, 10, 5, 2, 1}, money[7], a, i;
scanf("%d\n", &a);
printf("%d\n", a);

for ( i = 0; i < 7; i++)


{
money[i]= a/bNote[i];
a= a% bNote[i];
}
for ( i = 0; i < 7; i++)
{
printf("%d nota(s) de R$ %d,00\n", money[i], bNote[i]);
}

return 0;
}
OUTPUT
Problem-1019
#include<stdio.h>
#include<math.h>

int main(){
int a, hours, minutes, second;
scanf("%d\n", &a);
hours= a/3600;
second= a%3600;
minutes= second/60;
second= second%60;
printf("%d:%d:%d\n", hours, minutes, second);

return 0;
}
OUTPUT

Problem-1020
#include<stdio.h>
#include<math.h>

int main(){
int a, years, months, days;
scanf("%d\n", &a);
years= a/365;
days= a%365;
months= days/30;
days= days%30;

printf("%d ano(s)\n%d mes(es)\n%d dia(s)\n", years, months, days);

return 0;
}
OUTPUT

You might also like