…………………………………………………………………………

solution no 1001

…………………………………………………………………………..

Read 2 variables, named A and B and make the sum of these two variables, assigning its result to the variable X. Print X as shown below. Print endline after the result otherwise you will get “Presentation Error”.

  1. #include
  2. int main()
  3. {
  4. int A,B,X;
  5. scanf(“%d %d”, &A, &B); //input a and b
  6. X=A+B;  //addition a and b
  7. printf(“X = %d\n”,X);
  8. return 0;
  9. }

…………………………………………………………………………

solution no 1002

…………………………………………………………………………..

The formula to calculate the area of a circumference is defined as A = π . R2. Considering to this problem that π = 3.14159:

Calculate the area using the formula given in the problem description.

#include
int main()
{
    double R,A;
    scanf("%lf", &R);
    A = 3.14159 * R * R;  //Area: pi × base × height (pi x 10 x 10)
    printf("A=%.4lf\n", A); //.4lf is .0000
    return 0;
}

…………………………………………………………………………

solution no 1003

…………………………………………………………………………..

Read two integer values, in this case, the variables A and B. After this, calculate the sum between them and assign it to the variable SOMA. Write the value of this variable.

#include 

int main()
{
 int x;
 int y;

   scanf("%d", &x);
   scanf("%d", &y);
   printf("SOMA = %d\n", x + y); //x and y addition

 return 0;
}

…………………………………………………………………………

solution no 1004

…………………………………………………………………………..

Read two integer values. After this, calculate the product between them and store the result in a variable named PROD. Print the result like the example below. Do not forget to print the end of line after the result, otherwise you will receive “Presentation Error”.

#include <stdio.h>
int main()
{
 int x,y;

 scanf("%d%d", &x, &y);
 printf("PROD = %d\n", x * y);//multiply

 return 0;
}

…………………………………………………………………………

solution no 1005

…………………………………………………………………………..

Read two floating points’ values of double precision A and B, corresponding to two student’s grades. After this, calculate the student’s average, considering that grade A has weight 3.5 and B has weight 7.5. Each grade can be from zero to ten, always with one digit after the decimal point. Don’t forget to print the end of line after the result, otherwise you will receive “Presentation Error”. Don’t forget the space before and after the equal sign.

#include <stdio.h>
int main(){
    float x,y;
    scanf("%f %f", &x, &y);
    printf("MEDIA = %.5f\n", (x*3.5+y*7.5)/(3.5+7.5));
    return 0;
}

…………………………………………………………………………

solution no 1006

…………………………………………………………………………..

Read three values (variables A, B and C), which are the 
three student's grades. Then,
 calculate the average, considering that grade A has weight 2,
 grade B has weight 3 and 
the grade C has weight 5. Consider that each grade can go
 from 0 to 10.0, always with one decimal place.

#include

int main()
{
   double a, b, c, media;
   scanf("%lf%lf%lf", &a, &b, &c);
   media = (a/10 * 2) + (b/10 * 3) + (c/10 * 5);
   printf("MEDIA = %.1lf\n", media);
   return 0;
}

…………………………………………………………………………

solution no 1007

…………………………………………………………………………..


#include<stdio.h>
int main()
{
    int a,b,c,d,x;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    x=(a*b)-(c*d);
    printf("DIFERENCA = %d\n",x);
    return 0;

}

…………………………………………………………………………

solution no 1008

…………………………………………………………………………..

Write a program that reads an employee’s number, his/her worked hours number in a month and the amount he received per hour. Print the employee’s number and salary that he/she will receive at end of the month, with two decimal places.

  • Don’t forget to print the line’s end after the result, otherwise you will receive “Presentation Error”.
  • Don’t forget the space before and after the equal signal and after the U$.
#include<stdio.h>
int main()
{
    int num,hour;
    float sal ,total;
    scanf(“%d”,&num);
    scanf(“%d”,&hour);
    scanf(“%f”,&sal);
    total=hour*sal;
    printf(“NUMBER = %d\n”,num);
    printf(“SALARY = U$ %.2f\n”,total);
    return 0;
 
}

…………………………………………………………………………

solution no 1009

…………………………………………………………………………..

Make a program that reads a seller’s name, his/her fixed salary and the sale’s total made by himself/herself in the month (in money). Considering that this seller receives 15% over all products sold, write the final salary (total) of this seller at the end of the month , with two decimal places.

#include<stdio.h>
//#include<string.h>
int main()
{
    char x[100];
    double a;
    double c,b;
    scanf(“%s”,x);
    scanf(“%lf”,&a);
    scanf(“%lf”,&b);
    c=a+(b*0.15);
    //printf(“%s\n”, x);
    printf(“TOTAL = R$ %.2lf\n”,c);
    return 0;
}

…………………………………………………………………………

solution no 1010

…………………………………………………………………………..

In this problem, the task is to read a code of a product 1, the number of units of product 1, the price for one unit of product 1, the code of a product 2, the number of units of product 2 and the price for one unit of product 2. After this, calculate and show the amount to be paid.

#include<stdio.h>
int main()
{
    int a,b,c,d,i;
    float x,y;
    float p,q,m;


        scanf(“%d %d %f”,&a,&b,&x);
        scanf(“%d %d %f”,&c,&d,&y);


    p=x*b;
    q=y*d;
    m=p+q;
    printf(“VALOR A PAGAR: R$ %.2f”,m);

    return 0;
}

…………………………………………………………………………

solution no 1011

…………………………………………………………………………..

Make a program that calculates and shows the volume of a sphere being provided the value of its radius (R) . The formula to calculate the volume is: (4/3) * pi * R3. Consider (assign) for pi the value 3.14159.

Tip: Use (4/3.0) or (4.0/3) in your formula, because some languages (including C++) assume that the division’s result between two integers is another integer. 

#include 
#include 

int main()
{
 int a;

 scanf("%i", &a);
 printf("VOLUME = %.3lf\n", (4 * 3.14159 * pow(a, 3)) / 3);

 return 0;
}

…………………………………………………………………………

solution no 1012

…………………………………………………………………………..

Make a program that reads three floating point values: A, B and C. Then, calculate and show:
a) the area of the rectangled triangle that has base A and height C.
b) the area of the radius’s circle C. (pi = 3.14159)
c) the area of the trapezium which has A and B by base, and C by height.
d) the area of ​​the square that has side B.
e) the area of the rectangle that has sides A and B.

#include <stdio.h>

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

 scanf("%lf %lf %lf", &a, &b, &c);
 printf("TRIANGULO: %.3lf\n", (a * c) / 2);
 printf("CIRCULO: %.3lf\n", c * c * 3.14159);
 printf("TRAPEZIO: %.3lf\n", ((a + b) / 2) * c);
 printf("QUADRADO: %.3lf\n", b * b);
 printf("RETANGULO: %.3lf\n", a * b);

 return 0;
}

…………………………………………………………………………

solution no 1013

…………………………………………………………………………..

Make a program that reads 3 integer values and present the greatest one followed by the message “eh o maior”. Use the following formula:

#include <stdio.h>

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

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

 tmp = a;
 if(a < b || a < c){
  if(b < c){
   tmp = c;
  }else{
   tmp = b;
  }
 }

 printf("%d eh o maior\n", tmp);

 return 0;
}

…………………………………………………………………………

solution no 1014

…………………………………………………………………………..

Calculate a car’s average consumption being provided the total distance traveled (in Km) and the spent fuel total (in liters).

#include <stdio.h>

int main()
{
 double a, b;

 scanf("%lf %lf", &a, &b);

 printf("%.3lf km/l\n", a / b);

 return 0;
}

…………………………………………………………………………

solution no 1015

…………………………………………………………………………..

Read the four values corresponding to the x and y axes of two points in the plane, p1 (x1, y1) and p2 (x2, y2) and calculate the distance between them, showing four decimal places after the comma, according to the formula:

Distance = 

#include <stdio.h>
#include <math.h>

int main()
{
 double x1, x2, y1, y2, dist;

 scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

 dist = sqrt(pow(x2-x1,2)+pow(y2-y1,2));

 printf("%.4lf\n", dist);
 return 0;
}