LAB ASSIGNMENT 2: Basic ConditionalStatements(if-else,Loop)
Problem Number: Beecrowd 1050
Problem Name: DDD
Problem Link: https://judge.beecrowd.com/en/problems/view/1050
Problem Understanding Summary:
The task is to read a integer value and check what is the destination.
IPO chart:
Input Processing Output
One integer value 1.read a integer value. 1.print city name
2.check if this integer value orresponding to the input
match with the following integer.
table list.
3.print the city name.
Solution Code for the Problem:
#include <stdio.h>
int main() {
int n;
scanf("%d",&n);
if( n==61)
{
printf("Brasilia\n");
}
else if(n==71)
{
printf("Salvador\n");
}
else if(n==21)
{
printf("Rio de Janeiro\n");
}
else if(n==11)
{
printf("Sao Paulo\n");
}
else if(n==32)
{
printf("Juiz de Fora\n");
}
else if(n==19)
{
printf("Campinas\n");
}
else if(n==27)
{
printf("Vitoria\n");
}
else if(n==31)
{
printf("Belo Horizonte\n");
}
else
{
printf("DDD nao cadastrado\n");
}
return 0;
}
Learnings (Describe about new learnings after solving this problem):
I have learn how to check the input number is same with the following number in
question.
LAB ASSIGNMENT 2: Basic ConditionalStatements(if-else,Loop)
Problem Number: 1067
Problem Name: Odd Number
Problem Link: https://judge.beecrowd.com/en/problems/view/1067
Problem Understanding Summary:
The task is to read an integer value and print odd numbers from 1 to input integer.and
print all the odd numbers in one line and consider that if input integer is odd number it
will be also print in line.
IPO chart:
Input Processing Output
One integer value 1.Read integer value 1.Print all the odd number.
2.create a for loop ,loop
will break when i ==x.
3.there will a condition in
loop and that is if the
number is divisible by 2
then its not an odd number.
Solution Code for the Problem:
#include <stdio.h>
int main() {
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
if(i%2 != 0)
{
printf("%d\n",i);
}
}
return 0;
}
Learnings (Describe about new learnings after solving this problem):
I have learnt to create a loop and check the condition is true or false.