SlideShare a Scribd company logo
Rajshahi University of Engineering and Technology
“Heavens Light Is Our Guide”
Department of Electrical & Computer Engineering (ECE)
Assignment
Course No: ECE-1103.
Course Title: Computer Programming.
Assignment Name: Solving 50 programming problems.
Submitted To: Submitted By:
Sagor Chandro Bakchy.
Assistant Professor,
Department of Electrical & Computer
Engineering, RUET
MD. Samiul Haque Biswas.
Roll: 2010052.
Session: 2020-21
BeeCrowd ID link: https://www.beecrowd.com.br/judge/en/profile/692469
Problem No: 1051
Solution Code:
#include <stdio.h>
int main()
{
float salary;
scanf("%f", &salary);
if (salary <= 2000)
{
printf("Isenton");
}
else if (salary <= 3000)
{
printf("R$ %.2fn", (salary-2000)*0.08);
}
else if (salary <= 4500)
{
printf("R$ %.2fn", 80+((salary-3000)*0.18));
}
else if(salary>4500)
{
printf("R$ %.2fn", 350+((salary-4500)*0.28));
}
return 0;
}
Problem No: 1052
Solution Code:
#include <stdio.h>
int main()
{
int a;
scanf("%d", &a);
switch (a)
{
case 1:
printf("Januaryn");
break;
case 2:
printf("Februaryn");
break;
case 3:
printf("Marchn");
break;
case 4:
printf("Apriln");
break;
case 5:
printf("Mayn");
break;
case 6:
printf("Junen");
break;
case 7:
printf("Julyn");
break;
case 8:
printf("Augustn");
break;
case 9:
printf("Septembern");
break;
case 10:
printf("Octobern");
break;
case 11:
printf("Novembern");
break;
case 12:
printf("Decembern");
break;
}
return 0;
}
Problem NO: 1059
Solution Code:
#include <stdio.h>
int main()
{
for (int i = 2; i < 101; i = i + 2)
{
printf("%dn", i);
}
return 0;
}
Problem No: 1061
Solution Code:
#include <stdio.h>
int main()
{
int h, hh, hr, m, mm, d, dm, s, ss;
scanf("Dia %d", &d);
scanf("%d : %d : %dn", &h, &m, &s);
scanf("Dia %d", &dm);
scanf("%d : %d : %d", &hh, &mm, &ss);
s = ss - s;
m = mm - m;
h = hh - h;
d = dm - d;
if (s < 0)
{
s += 60;
m--;
}
if (m < 0)
{
m += 60;
h--;
}
if (h < 0)
{
h += 24;
d--;
}
printf("%d dia(s)n", d);
printf("%d hora(s)n", h);
printf("%d minuto(s)n", m);
printf("%d segundo(s)n", s);
return 0;
}
Problem No: 1060
Solution Code:
#include <stdio.h>
int main()
{
int t = 6,s=0;
while (t--)
{
float a;
scanf("%f", &a);
if (a > 0)
s++;
}
printf("%d valores positivosn", s);
return 0;
}
Problem No: 1061
Solution Code:
#include <stdio.h>
int main()
{
int h, hh, hr, m, mm, d, dm, s, ss;
scanf("Dia %d", &d);
scanf("%d : %d : %dn", &h, &m, &s);
scanf("Dia %d", &dm);
scanf("%d : %d : %d", &hh, &mm, &ss);
s = ss - s;
m = mm - m;
h = hh - h;
d = dm - d;
if (s < 0)
{
s += 60;
m--;
}
if (m < 0)
{
m += 60;
h--;
}
if (h < 0)
{
h += 24;
d--;
}
printf("%d dia(s)n", d);
printf("%d hora(s)n", h);
printf("%d minuto(s)n", m);
printf("%d segundo(s)n", s);
return 0;
}
Problem No: 1064
Solution Code:
#include <stdio.h>
int main()
{
int t = 6,s=0; //SamiulHaque
float x=0;
while (t--)
{
float a;
scanf("%f", &a);
if (a > 0)
{
s++;
x = x + a;
}
}
printf("%d valores positivosn", s);
printf("%.1fn", float(x / s));
return 0;
}
Problem No: 1065
Solution Code:
#include <stdio.h>
int main()
{
int t = 5, s = 0;
while (t--)
{
int a;
scanf("%d", &a);
if (a % 2 == 0)
s++;
}
printf("%d valores paresn", s);
return 0;
}
Problem No: 1066
Solution Code:
#include <stdio.h>
int main()
{
int t = 5, e = 0, o = 0, p = 0, n = 0;
while (t--)
{
int a;
scanf("%d", &a);
if (a % 2 == 0 || (a*(-1))%2==0) //SamiulHaque
{
e++;
}
else
{
o++;
}
if (a > 0)
{
p++;
}
else if(a<0)
{
n++;
}
}
printf("%d valor(es) par(es)n", e);
printf("%d valor(es) impar(es)n", o);
printf("%d valor(es) positivo(s)n", p);
printf("%d valor(es) negativo(s)n", n);
return 0;
}
Problem No: 1067
Solution Code:
#include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
for (int i = 1; i < t + 1; i=i+2)
{
printf("%dn", i);
}
return 0;
}
Problem No: 1070
Solution Code:
#include <stdio.h>
int main()
{
int x;
scanf("%d", &x);
if (x % 2 == 0)
{
for (int i = x+1; i < x + 12; i = i + 2)
{
printf("%dn", i);
}
}
else if (x % 2 != 0)
{
for (int i = x; i < x + 11; i = i + 2)
{
printf("%dn", i);
}
}
return 0;}
Problem No: 1071
Solution Code:
#include <stdio.h>
int main()
{
int x, y, s = 0;
scanf("%d %d", &x, &y);
if (x > y)
{
for (int i = y+1; i < x; i++)
{
if (i % 2 != 0)
s = s + i;
}
printf("%dn", s);
}
else if (x < y)
{
for (int i = x+1; i < y; i = i++)
{
if (i % 2 != 0)
s = s + i;
}
printf("%dn", s);
}
else
{
printf("0n");
}
}
Problem No: 1072
Solution Code:
#include <stdio.h>
int main()
{
int n,c=0,d=0;
scanf("%d",&n);
for (int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
if (x >= 10 && x <= 20)
{
c++;
}
else
{
d++; } }
printf("%d inn", c);
printf("%d outn", d);
return 0;
}
Problem No: 1073
Solution Code:
#include <stdio.h>
int main()
{
long long int n;
scanf("%lld", &n);
if (n % 2 == 0)
{
for (long long int i = 2; i < n + 1; i=i+2)
{
printf("%lld^2 = %lldn",i,i*i);
}
}
else
{
for(long long int i=2; i<n; i=i+2)
{
printf("%lld^2 = %lldn",i,i*i);
}
}
}
Problem No: 1074
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
while (n--)
{
int x;
scanf("%d", &x);
if (x == 0)
{
printf("NULLn");
}
else if (x % 2 == 0 && x > 0)
{
printf("EVEN POSITIVEn");
}
else if (x % 2 == 0 && x < 0)
{
printf("EVEN NEGATIVEn");
}
else if (x % 2 != 0 && x < 0)
{
printf("ODD NEGATIVEn");
}
else if (x % 2 != 0 && x > 0)
{
printf("ODD POSITIVEn");
}
}
return 0;
}
Problem No: 1075
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= 10000; i++)
{
if (i % n == 2)
printf("%dn",i);
}
return 0;
}
Problem No: 1078
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= 10; i++)
{
printf("%d x %d = %dn", i, n, i * n);
}
return 0;
}
Problem No: 1079
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
while (n--)
{
float a, b, c;
scanf("%f %f %f", &a, &b, &c);
printf("%.1fn",(a*2+b*3+c*5)/10);
}
return 0;}
Problem No: 1080
Solution Code:
#include <stdio.h>
int main()
{
int highest = -999;
int a[100];
for (int i = 0; i < 100; i++)
{
scanf("%d", &a[i]);
}
for (int i = 0; i < 100; i++)
{
if (highest < a[i])
highest = a[i];
}
printf("%dn", highest);
for (int i = 0; i < 100; i++)
{
if (a[i] == highest)
printf("%dn", i + 1);
}
}
Problem No: 1094
Solution Code:
#include <stdio.h>
int main()
{
int n, p = 0, q = 0, r = 0, t;
float e, f, g;
scanf("%d", &n);
while (n--)
{
int x;
char a;
scanf("%d %c", &x, &a);
if (a == 'C')
{
p = p + x;
}
else if (a == 'R')
{
q = q + x;
}
else if (a == 'S')
{
r = r + x;
}
}
t = p + q + r;
e = float((p * 100.00) / t);
f = float((q * 100.00) / t);
g = float((r * 100.00) / t);
printf("Total: %d cobaiasn", t);
printf("Total de coelhos: %dn", p);
printf("Total de ratos: %dn", q);
printf("Total de sapos: %dn", r);
printf("Percentual de coelhos: %.2f %%n", e);
printf("Percentual de ratos: %.2f %%n", f);
printf("Percentual de sapos: %.2f %%n", g);
return 0;
}
Problem No: 1095
Solution Code:
#include <stdio.h>
int main()
{
int sum = 60;
for (int i = 1; i <= 37; i = i+3)
{
printf("I=%d J=%dn", i, sum);
sum = sum - 5;
}
return 0;
}
Problem No: 1096
Solution Code:
#include <stdio.h>
int main()
{
for (int i = 1; i <= 9; i = i + 2)
{
printf("I=%d J=7n", i);
printf("I=%d J=6n", i);
printf("I=%d J=5n", i);
}
return 0;
}
Problem No: 1097
Solution Code:
#include <stdio.h>
int main()
{
int a = 7, b = 6, c = 5;
for (int i = 1; i <= 9; i = i + 2)
{
printf("I=%d J=%dn", i, a);
printf("I=%d J=%dn", i, b);
printf("I=%d J=%dn", i, c);
a = a + 2;
b = b + 2;
c = c + 2;
}
return 0;
}
Problem No: 1098
Solution Code:
#include <stdio.h>
int main()
{
float i, j, a = 1.2, b = 2.2, c = 3.2;
printf("I=0 J=1n");
printf("I=0 J=2n");
printf("I=0 J=3n");
for (i = 0.2; i < 1; i = i + 0.2)
{
printf("I=%0.1f J=%0.1fn", i, a);//SamiulHaque
printf("I=%0.1f J=%0.1fn", i, b);
printf("I=%0.1f J=%0.1fn", i, c);
a = a + 0.2;
b = b + 0.2;
c = c + 0.2;
}
printf("I=1 J=2n");
printf("I=1 J=3n");
printf("I=1 J=4n");
a=2.2,b=3.2,c=4.2;
for (i = 1.2; i < 2; i = i + 0.2)
{
printf("I=%0.1f J=%0.1fn", i, a);//SamiulHaque
printf("I=%0.1f J=%0.1fn", i, b);
printf("I=%0.1f J=%0.1fn", i, c);
a = a + 0.2;
b = b + 0.2;
c = c + 0.2;
}
printf("I=2 J=3n");
printf("I=2 J=4n");
printf("I=2 J=5n");
return 0;
}
Problem No: 1099
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
while (n--)
{
int x, y, sum = 0;
scanf("%d %d", &x, &y);
if (x == y)
{
printf("0n");
}
if (x > y && y % 2 == 0)
{
for (int i = y + 1; i < x; i = i + 2)
{
sum = sum + i;
}
printf("%dn", sum);
}
else if (x > y && y % 2 != 0)
{
for (int i = y + 2; i < x; i = i + 2)
{
sum = sum + i;
}
printf("%dn", sum);
}
else if (y > x && x % 2 == 0)
{
for (int i = x + 1; i < y; i = i + 2)
{
sum = sum + i;
}
printf("%dn", sum);
}
else if(y>x && x%2!=0)
{
for (int i = x + 2; i < y; i = i + 2)
{
sum = sum + i;
}
printf("%dn", sum);
}
}
return 0;
}
Problem No: 1101
Solution Code:
#include <stdio.h>
int main()
{
int m, n;
for (int i = 0; i >= 0; i++)
{
int sum=0;
scanf("%d %d", &m, &n);
if (m > 0 && n > 0)
{
if (m >= n)
{
for (int j = n; j < m + 1; j++)
{
printf("%d ", j);
sum = sum + j;
}
printf("Sum=%dn", sum);
}
else
{
for (int j = m; j < n + 1; j++)
{
printf("%d ", j);
sum = sum + j;
}
printf("Sum=%dn", sum);
}
}
else
{
break;
}
}
return 0;
}
Problem No: 1113
Solution Code:
#include <stdio.h>
int main()
{
for (int i = 0; i >= 0; i++)
{
int x, y, r;
scanf("%d %d", &x, &y);
r = x - y;
if (r == 0)
{
break;
}
else if (r > 0)
{
printf("Decrescenten");
}
else if (r < 0)
{
printf("Crescenten");
}
}
return 0;
}
Problem No: 1114
Solution Code:
#include <stdio.h>
int main()
{
for (int i = 0; i >= 0; i++)
{
int n;
scanf("%d", &n);
if (n == 2002)
{
printf("Acesso Permitidon");
break;
}
else
{
printf("Senha Invalidan");
}
}
return 0;
}
Problem No: 1115
Solution Code:
#include <stdio.h>
int main()
{
for (int i = 0; i >= 0; i++)
{
int x, y;
scanf("%d %d", &x, &y);
if (x == 0 || y == 0)
{
break;
}
else if (x > 0 && y > 0)
{
printf("primeiron");
}
else if (x > 0 && y < 0)
{
printf("quarton");
}
else if (x < 0 && y < 0)
{
printf("terceiron");
}
else if (x < 0 && y > 0)
{
printf("segundon");
}
}
return 0;
}
Problem No: 1116
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
while (n--)
{
float x, y;
scanf("%f %f", &x, &y);
if (y == 0)
{
printf("divisao impossiveln");
}
else
{
printf("%.1fn", (x / y));
}
}
return 0;
}
Problem No: 1117
Solution Code:
#include <stdio.h>
int main()
{
float x, sum;
int j = 1;
while (j < 3)
{
scanf("%f", &x);
if (x >= 0.0 && x <= 10.0)
{
sum = sum + x;
j++;
continue;
}
else
{
printf("nota invalidan");
continue;
}
}
printf("media = %.2fn", sum / 2.0);
return 0;
}
Problem No: 1118
Solution Code:
#include <stdio.h>
int main()
{
int x = 1, j = 0;
float s[2], a, avg;
while (x != 2)
{
if (x == 1)
{
while (j <= 1)
{
scanf("%f", &a);
if (a >= 0.0 && a <= 10.0)
{
s[j] = a;//SamiulHaque
j++;
}
else
{
printf("nota invalidan");
}
}
avg = (s[0] + s[1]) / 2.0;
printf("media = %.2fn", avg);
}
printf("novo calculo (1-sim 2-nao)n");
scanf("%d", &x);
j = 0;
continue;
}
return 0;
}
Problem No: 1132
Solution Code:
#include <stdio.h>
int main()
{
int x, y, add = 0;
scanf("%d %d", &x, &y);
if (x == y)
{
printf("0");
}
else if (x > y)
{
for (int i = y; i <=x; i++)
{
if (i % 13 != 0)
{
add = add + i;
}
}
printf("%dn", add);
}
else if (x < y)
{
for (int i = x; i <=y; i++)
{
if (i % 13 != 0)
{
add = add + i;
}
}
printf("%dn", add);
}
return 0;
}
Problem No: 1133
Solution Code:
#include <stdio.h>
int main()
{
int x, y, a = 0, b = 0;
scanf("%d %d", &x, &y);
if (x > y)
{
for (int i = y + 1; i < x; i++)
{
if (i % 5 == 2 || i % 5 == 3)
{
printf("%dn", i);
}
}
}
else if (x < y)
{
for (int i = x + 1; i < y; i++)
{
if (i % 5 == 2 || i % 5 == 3)
{
printf("%dn", i);
}
}
}
return 0;}
Problem No: 1134
Solution Code:
#include <stdio.h>
int main()
{
int a = 0, b = 0, c = 0;
for (int i = 1; i > 0; i++)
{
int n;
scanf("%d", &n);
if(n==1)
{
a++;
}
else if(n==2)
{
b++;
}
else if(n==3)
{
c++;
}
else if(n==4)
{
break;
}
else
{
continue;
}
}
printf("MUITO OBRIGADOn");
printf("Alcool: %dn", a);
printf("Gasolina: %dn", b);
printf("Diesel: %dn", c);
return 0;
}
Problem No: 1142
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a = 1, b = 2, c = 3;
while (n--)
{
printf("%d ", a);
printf("%d ", b);
printf("%d ", c);
printf("PUMn");
a = a + 4;
b = b + 4;
c = c + 4;
}
return 0;
}
Problem No: 1143
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
printf("%d %d %dn", i, i * i, i * i * i);
}
return 0;
}
Problem No:1144
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
printf("%d %d %dn", i, i * i, i * i * i);
printf("%d %d %dn", i, (i * i) + 1, (i * i * i) + 1);
}
return 0;
}
Problem No: 1145
Solution Code:
#include <stdio.h>
int main()
{
int x, y, c = 0;
scanf("%d %d", &x, &y);
for (int i = 1; i <= y; i++)
{
if (i % x != 0)
{
printf("%d ", i);//SamiulHaque
}
else if (i % x == 0)
{
printf("%dn",i);
}
}
return 0;
}
Problem No: 1146
Solution Code:
#include <stdio.h>
int main()
{
int x;
while (x != 0)
{
scanf("%d", &x);
for (int i = 1; i <= x; i++)
{
if (i % x != 0)
{
printf("%d ", i);//SamiulHaque
}
else if (i % x == 0)
{
printf("%dn", i);
}
}
}
return 0;
}
Problem No:1149
Solution Code:
#include <stdio.h>
int main()
{
int n, a, sum = 0;
scanf("%d ", &a);
for (int i = 0; i >= 0; i++)
{
scanf("%d", &n);
if (n > 0)
{
for (int i = a; i < a + n; i++)
{
sum = sum + i;
}
printf("%dn", sum);
break;
}
else
{
continue;
}
}
return 0;
}
Problem No: 1150
Solution Code:
#include <stdio.h>
int main()
{
int x, z, sum = 0, c=0;
scanf("%d", &x);
for (int i = 0; i >= 0; i++)
{
scanf("%d", &z);
if (z <= x)
{
continue;
}
else
{
break;
}
}
for (int i = 0; i >= 0; i++)
{
sum = x + i + sum;
c++;
if (sum >= z)
{
break;
}
}
printf("%dn", c);
return 0;
}
Problem No: 1151
Solution Code:
#include <stdio.h>
int main()
{
int n, a = 0, b = 1, c;
scanf("%d", &n);
if (n == 1)
{
printf("%n", a);
}
else if (n == 2)
{
printf("%d %dn", a, b);
}
else
{
printf("%d %d", a, b);
for (int i = 2; i < n; ++i)
{
c = a + b;
printf(" %d", c);
a = b;
b = c;
}
printf("n");
}
return 0;
}
Problem No: 1153
Solution Code:
#include <stdio.h>
int main()
{
int n, fact = 1;
scanf("%d", &n);
if (n <= 1)
{
printf("1n");
}
else
{
for (int i = 1; i <= n; i++)
{
fact = fact * i;
}
printf("%dn", fact);
}
return 0;
}
Problem No: 1154
Solution Code:
#include <stdio.h>
int main()
{
float sum = 0, a = 0;
for (int i = 0; i >= 0; i++)
{
int x;
scanf("%d", &x);
if (x < 0)
{
break;
}
else if (x >= 0)
{
sum = sum + x;
a++;
}
}
printf("%.2fn", float(sum / a));
return 0;
}
Problem No: 1155
Solution Code:
#include <stdio.h>
int main()
{
float sum = 0;
for (float i = 1; i <= 100; i++)
{
sum = sum + (1 / i);
}
printf("%.2fn", sum);
return 0;
}
Problem No: 1156
Solution Code:
#include <stdio.h>
#include <math.h>
int main()
{
float sum = 0;
for (float i = 1, j = 0; i <= 39, j <= 20; i = i + 2, j++)
{
sum = sum + (i / pow(2, j));
}
printf("%.2fn", sum);
return 0;
}
Problem No: 1157
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
if (n % i == 0)
{
printf("%dn", i);
}
}
return 0;
}
Problem No: 1158
Solution Code:
#include <stdio.h>
int main()
{
int n;
scanf("%d",&n);
while (n--)
{
int x, y, sum = 0;
scanf("%d %d", &x, &y);
if (x % 2 == 0)
{
for (int i = x; i < x + 2 * y; i++)
{
if (i % 2 != 0)
{
sum = sum + i;
}
}
printf("%dn", sum);
}
else if (x % 2 != 0)
{
for (int i = x; i < x + 2 * y; i++)
{
if (i % 2 != 0)
{
sum = sum + i;
}
}
printf("%dn", sum);
}
}
return 0;
}
Problem No: 1159
Solution Code:
#include <stdio.h>
int main()
{
for (int i = 0; i >= 0; i++)
{
int x, sum = 0;
scanf("%d", &x);
if (x == 0)
{
break;
}
else
{
for (int i = x; i < x + 10; i++)
{
if (i % 2 == 0)
{
sum = sum + i;
}
else
{
continue;
}
}
printf("%dn", sum);
}
}
return 0;
}
Problem No: 1160
Solution Code:
#include <stdio.h>
int main()
{
int t, pa, pb, c;
double ga, gb, p, q;
scanf("%d", &t);
while (t--)
{
c = 0;
scanf("%d %d %lf %lf", &pa, &pb, &ga, &gb);
p = ga / 100;
q = gb / 100;
while (pa <= pb)
{
pa = pa + (pa * p);//SamiulHaque
pb = pb + (pb * q);
c++;
if (c > 100)
{
printf("Mais de 1 seculo.n");
break;
}
}
if (c <= 100)
{
printf("%d anos.n", c);
}
}
return 0;}
Submission Record:
Assignment_URI_Code_Solution_Roll_2010052 (1).pdf
Assignment_URI_Code_Solution_Roll_2010052 (1).pdf

More Related Content

Similar to Assignment_URI_Code_Solution_Roll_2010052 (1).pdf

programs
programsprograms
programs
Vishnu V
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
Jeff Tu Pechito
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
Syed Ahmed Zaki
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
manoj11manu
 
Lab Question
Lab QuestionLab Question
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
Cpds lab
Cpds labCpds lab
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignment
Zenith SVG
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
Include
IncludeInclude
Include
Angie Borda
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
ADA FILE
ADA FILEADA FILE
ADA FILE
Gaurav Singh
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
Ashutoshprasad27
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
Ashutoshprasad27
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdf
MuhammadMaazShaik
 
Pnno
PnnoPnno
C file
C fileC file
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
ArghodeepPaul
 

Similar to Assignment_URI_Code_Solution_Roll_2010052 (1).pdf (20)

programs
programsprograms
programs
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Lab Question
Lab QuestionLab Question
Lab Question
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignment
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Include
IncludeInclude
Include
 
C Programming
C ProgrammingC Programming
C Programming
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdf
 
Pnno
PnnoPnno
Pnno
 
C file
C fileC file
C file
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 

Recently uploaded

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 

Recently uploaded (20)

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 

Assignment_URI_Code_Solution_Roll_2010052 (1).pdf

  • 1. Rajshahi University of Engineering and Technology “Heavens Light Is Our Guide” Department of Electrical & Computer Engineering (ECE) Assignment Course No: ECE-1103. Course Title: Computer Programming. Assignment Name: Solving 50 programming problems. Submitted To: Submitted By: Sagor Chandro Bakchy. Assistant Professor, Department of Electrical & Computer Engineering, RUET MD. Samiul Haque Biswas. Roll: 2010052. Session: 2020-21
  • 2. BeeCrowd ID link: https://www.beecrowd.com.br/judge/en/profile/692469 Problem No: 1051 Solution Code: #include <stdio.h> int main() { float salary; scanf("%f", &salary); if (salary <= 2000) { printf("Isenton"); } else if (salary <= 3000) { printf("R$ %.2fn", (salary-2000)*0.08); } else if (salary <= 4500) { printf("R$ %.2fn", 80+((salary-3000)*0.18)); } else if(salary>4500) { printf("R$ %.2fn", 350+((salary-4500)*0.28)); } return 0; }
  • 3. Problem No: 1052 Solution Code: #include <stdio.h> int main() { int a; scanf("%d", &a); switch (a) { case 1: printf("Januaryn"); break; case 2: printf("Februaryn"); break; case 3: printf("Marchn"); break; case 4: printf("Apriln"); break; case 5: printf("Mayn"); break; case 6: printf("Junen"); break; case 7: printf("Julyn");
  • 4. break; case 8: printf("Augustn"); break; case 9: printf("Septembern"); break; case 10: printf("Octobern"); break; case 11: printf("Novembern"); break; case 12: printf("Decembern"); break; } return 0; } Problem NO: 1059 Solution Code: #include <stdio.h> int main() { for (int i = 2; i < 101; i = i + 2) { printf("%dn", i); } return 0;
  • 5. } Problem No: 1061 Solution Code: #include <stdio.h> int main() { int h, hh, hr, m, mm, d, dm, s, ss; scanf("Dia %d", &d); scanf("%d : %d : %dn", &h, &m, &s); scanf("Dia %d", &dm); scanf("%d : %d : %d", &hh, &mm, &ss); s = ss - s; m = mm - m; h = hh - h; d = dm - d; if (s < 0) { s += 60; m--; } if (m < 0) { m += 60; h--; } if (h < 0) { h += 24; d--;
  • 6. } printf("%d dia(s)n", d); printf("%d hora(s)n", h); printf("%d minuto(s)n", m); printf("%d segundo(s)n", s); return 0; } Problem No: 1060 Solution Code: #include <stdio.h> int main() { int t = 6,s=0; while (t--) { float a; scanf("%f", &a); if (a > 0) s++; } printf("%d valores positivosn", s); return 0; } Problem No: 1061 Solution Code: #include <stdio.h> int main() {
  • 7. int h, hh, hr, m, mm, d, dm, s, ss; scanf("Dia %d", &d); scanf("%d : %d : %dn", &h, &m, &s); scanf("Dia %d", &dm); scanf("%d : %d : %d", &hh, &mm, &ss); s = ss - s; m = mm - m; h = hh - h; d = dm - d; if (s < 0) { s += 60; m--; } if (m < 0) { m += 60; h--; } if (h < 0) { h += 24; d--; }
  • 8. printf("%d dia(s)n", d); printf("%d hora(s)n", h); printf("%d minuto(s)n", m); printf("%d segundo(s)n", s); return 0; } Problem No: 1064 Solution Code: #include <stdio.h> int main() { int t = 6,s=0; //SamiulHaque float x=0; while (t--) { float a; scanf("%f", &a); if (a > 0) { s++; x = x + a; } } printf("%d valores positivosn", s); printf("%.1fn", float(x / s)); return 0; }
  • 9. Problem No: 1065 Solution Code: #include <stdio.h> int main() { int t = 5, s = 0; while (t--) { int a; scanf("%d", &a); if (a % 2 == 0) s++; } printf("%d valores paresn", s); return 0; } Problem No: 1066 Solution Code: #include <stdio.h> int main() { int t = 5, e = 0, o = 0, p = 0, n = 0; while (t--) { int a; scanf("%d", &a); if (a % 2 == 0 || (a*(-1))%2==0) //SamiulHaque {
  • 10. e++; } else { o++; } if (a > 0) { p++; } else if(a<0) { n++; } } printf("%d valor(es) par(es)n", e); printf("%d valor(es) impar(es)n", o); printf("%d valor(es) positivo(s)n", p); printf("%d valor(es) negativo(s)n", n); return 0; } Problem No: 1067 Solution Code: #include<stdio.h> int main() { int t;
  • 11. scanf("%d", &t); for (int i = 1; i < t + 1; i=i+2) { printf("%dn", i); } return 0; } Problem No: 1070 Solution Code: #include <stdio.h> int main() { int x; scanf("%d", &x); if (x % 2 == 0) { for (int i = x+1; i < x + 12; i = i + 2) { printf("%dn", i); } } else if (x % 2 != 0) { for (int i = x; i < x + 11; i = i + 2) { printf("%dn", i); } } return 0;}
  • 12. Problem No: 1071 Solution Code: #include <stdio.h> int main() { int x, y, s = 0; scanf("%d %d", &x, &y); if (x > y) { for (int i = y+1; i < x; i++) { if (i % 2 != 0) s = s + i; } printf("%dn", s); } else if (x < y) { for (int i = x+1; i < y; i = i++) { if (i % 2 != 0) s = s + i; } printf("%dn", s); } else { printf("0n"); }
  • 13. } Problem No: 1072 Solution Code: #include <stdio.h> int main() { int n,c=0,d=0; scanf("%d",&n); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); if (x >= 10 && x <= 20) { c++; } else { d++; } } printf("%d inn", c); printf("%d outn", d); return 0; } Problem No: 1073 Solution Code: #include <stdio.h> int main()
  • 14. { long long int n; scanf("%lld", &n); if (n % 2 == 0) { for (long long int i = 2; i < n + 1; i=i+2) { printf("%lld^2 = %lldn",i,i*i); } } else { for(long long int i=2; i<n; i=i+2) { printf("%lld^2 = %lldn",i,i*i); } } } Problem No: 1074 Solution Code: #include <stdio.h> int main() { int n; scanf("%d", &n); while (n--) { int x;
  • 15. scanf("%d", &x); if (x == 0) { printf("NULLn"); } else if (x % 2 == 0 && x > 0) { printf("EVEN POSITIVEn"); } else if (x % 2 == 0 && x < 0) { printf("EVEN NEGATIVEn"); } else if (x % 2 != 0 && x < 0) { printf("ODD NEGATIVEn"); } else if (x % 2 != 0 && x > 0) { printf("ODD POSITIVEn"); } } return 0; } Problem No: 1075 Solution Code: #include <stdio.h> int main() {
  • 16. int n; scanf("%d", &n); for (int i = 1; i <= 10000; i++) { if (i % n == 2) printf("%dn",i); } return 0; } Problem No: 1078 Solution Code: #include <stdio.h> int main() { int n; scanf("%d", &n); for (int i = 1; i <= 10; i++) { printf("%d x %d = %dn", i, n, i * n); } return 0; } Problem No: 1079 Solution Code: #include <stdio.h> int main() { int n;
  • 17. scanf("%d", &n); while (n--) { float a, b, c; scanf("%f %f %f", &a, &b, &c); printf("%.1fn",(a*2+b*3+c*5)/10); } return 0;} Problem No: 1080 Solution Code: #include <stdio.h> int main() { int highest = -999; int a[100]; for (int i = 0; i < 100; i++) { scanf("%d", &a[i]); } for (int i = 0; i < 100; i++) { if (highest < a[i]) highest = a[i]; } printf("%dn", highest); for (int i = 0; i < 100; i++) { if (a[i] == highest) printf("%dn", i + 1);
  • 18. } } Problem No: 1094 Solution Code: #include <stdio.h> int main() { int n, p = 0, q = 0, r = 0, t; float e, f, g; scanf("%d", &n); while (n--) { int x; char a; scanf("%d %c", &x, &a); if (a == 'C') { p = p + x; } else if (a == 'R') { q = q + x; } else if (a == 'S') { r = r + x; } } t = p + q + r;
  • 19. e = float((p * 100.00) / t); f = float((q * 100.00) / t); g = float((r * 100.00) / t); printf("Total: %d cobaiasn", t); printf("Total de coelhos: %dn", p); printf("Total de ratos: %dn", q); printf("Total de sapos: %dn", r); printf("Percentual de coelhos: %.2f %%n", e); printf("Percentual de ratos: %.2f %%n", f); printf("Percentual de sapos: %.2f %%n", g); return 0; } Problem No: 1095 Solution Code: #include <stdio.h> int main() { int sum = 60; for (int i = 1; i <= 37; i = i+3) { printf("I=%d J=%dn", i, sum); sum = sum - 5; } return 0; } Problem No: 1096 Solution Code:
  • 20. #include <stdio.h> int main() { for (int i = 1; i <= 9; i = i + 2) { printf("I=%d J=7n", i); printf("I=%d J=6n", i); printf("I=%d J=5n", i); } return 0; } Problem No: 1097 Solution Code: #include <stdio.h> int main() { int a = 7, b = 6, c = 5; for (int i = 1; i <= 9; i = i + 2) { printf("I=%d J=%dn", i, a); printf("I=%d J=%dn", i, b); printf("I=%d J=%dn", i, c); a = a + 2; b = b + 2; c = c + 2; } return 0; }
  • 21. Problem No: 1098 Solution Code: #include <stdio.h> int main() { float i, j, a = 1.2, b = 2.2, c = 3.2; printf("I=0 J=1n"); printf("I=0 J=2n"); printf("I=0 J=3n"); for (i = 0.2; i < 1; i = i + 0.2) { printf("I=%0.1f J=%0.1fn", i, a);//SamiulHaque printf("I=%0.1f J=%0.1fn", i, b); printf("I=%0.1f J=%0.1fn", i, c); a = a + 0.2; b = b + 0.2; c = c + 0.2; } printf("I=1 J=2n"); printf("I=1 J=3n"); printf("I=1 J=4n"); a=2.2,b=3.2,c=4.2; for (i = 1.2; i < 2; i = i + 0.2) { printf("I=%0.1f J=%0.1fn", i, a);//SamiulHaque printf("I=%0.1f J=%0.1fn", i, b); printf("I=%0.1f J=%0.1fn", i, c);
  • 22. a = a + 0.2; b = b + 0.2; c = c + 0.2; } printf("I=2 J=3n"); printf("I=2 J=4n"); printf("I=2 J=5n"); return 0; } Problem No: 1099 Solution Code: #include <stdio.h> int main() { int n; scanf("%d", &n); while (n--) { int x, y, sum = 0; scanf("%d %d", &x, &y); if (x == y) { printf("0n"); } if (x > y && y % 2 == 0) { for (int i = y + 1; i < x; i = i + 2) {
  • 23. sum = sum + i; } printf("%dn", sum); } else if (x > y && y % 2 != 0) { for (int i = y + 2; i < x; i = i + 2) { sum = sum + i; } printf("%dn", sum); } else if (y > x && x % 2 == 0) { for (int i = x + 1; i < y; i = i + 2) { sum = sum + i; } printf("%dn", sum); } else if(y>x && x%2!=0) { for (int i = x + 2; i < y; i = i + 2) { sum = sum + i; } printf("%dn", sum); } }
  • 24. return 0; } Problem No: 1101 Solution Code: #include <stdio.h> int main() { int m, n; for (int i = 0; i >= 0; i++) { int sum=0; scanf("%d %d", &m, &n); if (m > 0 && n > 0) { if (m >= n) { for (int j = n; j < m + 1; j++) { printf("%d ", j); sum = sum + j; } printf("Sum=%dn", sum); } else { for (int j = m; j < n + 1; j++) { printf("%d ", j); sum = sum + j;
  • 25. } printf("Sum=%dn", sum); } } else { break; } } return 0; } Problem No: 1113 Solution Code: #include <stdio.h> int main() { for (int i = 0; i >= 0; i++) { int x, y, r; scanf("%d %d", &x, &y); r = x - y; if (r == 0) { break; } else if (r > 0) { printf("Decrescenten"); }
  • 26. else if (r < 0) { printf("Crescenten"); } } return 0; } Problem No: 1114 Solution Code: #include <stdio.h> int main() { for (int i = 0; i >= 0; i++) { int n; scanf("%d", &n); if (n == 2002) { printf("Acesso Permitidon"); break; } else { printf("Senha Invalidan"); } } return 0; } Problem No: 1115
  • 27. Solution Code: #include <stdio.h> int main() { for (int i = 0; i >= 0; i++) { int x, y; scanf("%d %d", &x, &y); if (x == 0 || y == 0) { break; } else if (x > 0 && y > 0) { printf("primeiron"); } else if (x > 0 && y < 0) { printf("quarton"); } else if (x < 0 && y < 0) { printf("terceiron"); } else if (x < 0 && y > 0) { printf("segundon"); } }
  • 28. return 0; } Problem No: 1116 Solution Code: #include <stdio.h> int main() { int n; scanf("%d", &n); while (n--) { float x, y; scanf("%f %f", &x, &y); if (y == 0) { printf("divisao impossiveln"); } else { printf("%.1fn", (x / y)); } } return 0; } Problem No: 1117 Solution Code: #include <stdio.h> int main()
  • 29. { float x, sum; int j = 1; while (j < 3) { scanf("%f", &x); if (x >= 0.0 && x <= 10.0) { sum = sum + x; j++; continue; } else { printf("nota invalidan"); continue; } } printf("media = %.2fn", sum / 2.0); return 0; } Problem No: 1118 Solution Code: #include <stdio.h> int main() { int x = 1, j = 0;
  • 30. float s[2], a, avg; while (x != 2) { if (x == 1) { while (j <= 1) { scanf("%f", &a); if (a >= 0.0 && a <= 10.0) { s[j] = a;//SamiulHaque j++; } else { printf("nota invalidan"); } } avg = (s[0] + s[1]) / 2.0; printf("media = %.2fn", avg); } printf("novo calculo (1-sim 2-nao)n"); scanf("%d", &x); j = 0; continue; } return 0;
  • 31. } Problem No: 1132 Solution Code: #include <stdio.h> int main() { int x, y, add = 0; scanf("%d %d", &x, &y); if (x == y) { printf("0"); } else if (x > y) { for (int i = y; i <=x; i++) { if (i % 13 != 0) { add = add + i; } } printf("%dn", add); } else if (x < y) { for (int i = x; i <=y; i++) { if (i % 13 != 0) {
  • 32. add = add + i; } } printf("%dn", add); } return 0; } Problem No: 1133 Solution Code: #include <stdio.h> int main() { int x, y, a = 0, b = 0; scanf("%d %d", &x, &y); if (x > y) { for (int i = y + 1; i < x; i++) { if (i % 5 == 2 || i % 5 == 3) { printf("%dn", i); } } } else if (x < y) { for (int i = x + 1; i < y; i++) { if (i % 5 == 2 || i % 5 == 3)
  • 33. { printf("%dn", i); } } } return 0;} Problem No: 1134 Solution Code: #include <stdio.h> int main() { int a = 0, b = 0, c = 0; for (int i = 1; i > 0; i++) { int n; scanf("%d", &n); if(n==1) { a++; } else if(n==2) { b++; } else if(n==3) { c++; } else if(n==4)
  • 34. { break; } else { continue; } } printf("MUITO OBRIGADOn"); printf("Alcool: %dn", a); printf("Gasolina: %dn", b); printf("Diesel: %dn", c); return 0; } Problem No: 1142 Solution Code: #include <stdio.h> int main() { int n; scanf("%d", &n); int a = 1, b = 2, c = 3; while (n--) { printf("%d ", a); printf("%d ", b); printf("%d ", c); printf("PUMn"); a = a + 4;
  • 35. b = b + 4; c = c + 4; } return 0; } Problem No: 1143 Solution Code: #include <stdio.h> int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { printf("%d %d %dn", i, i * i, i * i * i); } return 0; } Problem No:1144 Solution Code: #include <stdio.h> int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) {
  • 36. printf("%d %d %dn", i, i * i, i * i * i); printf("%d %d %dn", i, (i * i) + 1, (i * i * i) + 1); } return 0; } Problem No: 1145 Solution Code: #include <stdio.h> int main() { int x, y, c = 0; scanf("%d %d", &x, &y); for (int i = 1; i <= y; i++) { if (i % x != 0) { printf("%d ", i);//SamiulHaque } else if (i % x == 0) { printf("%dn",i); } } return 0; } Problem No: 1146 Solution Code:
  • 37. #include <stdio.h> int main() { int x; while (x != 0) { scanf("%d", &x); for (int i = 1; i <= x; i++) { if (i % x != 0) { printf("%d ", i);//SamiulHaque } else if (i % x == 0) { printf("%dn", i); } } } return 0; } Problem No:1149 Solution Code: #include <stdio.h> int main() { int n, a, sum = 0;
  • 38. scanf("%d ", &a); for (int i = 0; i >= 0; i++) { scanf("%d", &n); if (n > 0) { for (int i = a; i < a + n; i++) { sum = sum + i; } printf("%dn", sum); break; } else { continue; } } return 0; } Problem No: 1150 Solution Code: #include <stdio.h> int main() { int x, z, sum = 0, c=0;
  • 39. scanf("%d", &x); for (int i = 0; i >= 0; i++) { scanf("%d", &z); if (z <= x) { continue; } else { break; } } for (int i = 0; i >= 0; i++) { sum = x + i + sum; c++; if (sum >= z) { break; } } printf("%dn", c); return 0; } Problem No: 1151 Solution Code:
  • 40. #include <stdio.h> int main() { int n, a = 0, b = 1, c; scanf("%d", &n); if (n == 1) { printf("%n", a); } else if (n == 2) { printf("%d %dn", a, b); } else { printf("%d %d", a, b); for (int i = 2; i < n; ++i) { c = a + b; printf(" %d", c); a = b; b = c; } printf("n"); } return 0; }
  • 41. Problem No: 1153 Solution Code: #include <stdio.h> int main() { int n, fact = 1; scanf("%d", &n); if (n <= 1) { printf("1n"); } else { for (int i = 1; i <= n; i++) { fact = fact * i; } printf("%dn", fact); } return 0; } Problem No: 1154 Solution Code: #include <stdio.h> int main() { float sum = 0, a = 0;
  • 42. for (int i = 0; i >= 0; i++) { int x; scanf("%d", &x); if (x < 0) { break; } else if (x >= 0) { sum = sum + x; a++; } } printf("%.2fn", float(sum / a)); return 0; } Problem No: 1155 Solution Code: #include <stdio.h> int main() { float sum = 0; for (float i = 1; i <= 100; i++) { sum = sum + (1 / i); }
  • 43. printf("%.2fn", sum); return 0; } Problem No: 1156 Solution Code: #include <stdio.h> #include <math.h> int main() { float sum = 0; for (float i = 1, j = 0; i <= 39, j <= 20; i = i + 2, j++) { sum = sum + (i / pow(2, j)); } printf("%.2fn", sum); return 0; } Problem No: 1157 Solution Code: #include <stdio.h> int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { if (n % i == 0)
  • 44. { printf("%dn", i); } } return 0; } Problem No: 1158 Solution Code: #include <stdio.h> int main() { int n; scanf("%d",&n); while (n--) { int x, y, sum = 0; scanf("%d %d", &x, &y); if (x % 2 == 0) { for (int i = x; i < x + 2 * y; i++) { if (i % 2 != 0) { sum = sum + i; } } printf("%dn", sum);
  • 45. } else if (x % 2 != 0) { for (int i = x; i < x + 2 * y; i++) { if (i % 2 != 0) { sum = sum + i; } } printf("%dn", sum); } } return 0; } Problem No: 1159 Solution Code: #include <stdio.h> int main() { for (int i = 0; i >= 0; i++) { int x, sum = 0; scanf("%d", &x); if (x == 0) { break;
  • 46. } else { for (int i = x; i < x + 10; i++) { if (i % 2 == 0) { sum = sum + i; } else { continue; } } printf("%dn", sum); } } return 0; } Problem No: 1160 Solution Code: #include <stdio.h> int main() { int t, pa, pb, c; double ga, gb, p, q; scanf("%d", &t);
  • 47. while (t--) { c = 0; scanf("%d %d %lf %lf", &pa, &pb, &ga, &gb); p = ga / 100; q = gb / 100; while (pa <= pb) { pa = pa + (pa * p);//SamiulHaque pb = pb + (pb * q); c++; if (c > 100) { printf("Mais de 1 seculo.n"); break; } } if (c <= 100) { printf("%d anos.n", c); } } return 0;}