can rubber escape
#include<stdio.h>
int main(){
int n,count=0;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]%2!=0)
count++;
}
if (count>2)
printf("NO");
else
printf("YES");
return 0;
}
can share equally
#include<stdio.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);
if(a==0 && b%2==0)
printf("YES");
else if(a==0 && b%2!=0)
printf("NO");
else if((a+2*b)%2==0)
printf("YES");
else
printf("NO");
return 0;
}
Vowel consonant
#include<stdio.h>
int main(){
char a;
scanf("%c",&a);
if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
printf("Vowel");
else
printf("Consonant");
return 0;
}
even odd
#include<stdio.h>
int main(){
int a;
scanf("%d",&a);
if(a%2==0)
printf("Even");
else
printf("Odd");
return 0;
}
positive or negative
#include<stdio.h>
int main(){
int a;
scanf("%d",&a);
if(a>0)
printf("Positive Number");
else
printf("Negative Number");
return 0;
}
leap year or not
leap year or not
#include<stdio.h>
int main(){
int a;
scanf("%d",&a);
if(a%400==0)
printf("True");
else if(a%100==0)
printf("False");
else if(a%4==0)
printf("True");
else
printf("False");
return 0;
}
sum of elements with out loops
#include<stdio.h>
int main(){
int a,sum=0;
scanf("%d",&a);
int n[a];
for(int i=0;i<a;i++)
{
scanf("%d",&n[i]);
sum+=n[i];
}
printf("%d",sum);
return 0;
}
Grades of ride
#include<stdio.h>
int main(){
int h,s,sp;
scanf("%d%d%d",&h,&s,&sp);
if(h>50 && s>60 && sp>100)
printf("10");
else if(h>50 && s>60)
printf("9");
else if(s>60 && sp>100)
printf("8");
else if(h>50 && sp>100)
printf("7");
else if(h<=50 && s<=60 && sp<=100)
printf("5");
else
printf("6");
return 0;
}
Rain drop
#include<stdio.h>
int main(){
int a;
scanf("%d",&a);
if(a%3==0)
printf("Pling");
if(a%5==0)
printf("Plang");
if(a%7==0)
printf("Plong");
if(a%3!=0 && a%7!=0 && a%5!=0)
printf("%d",a);
return 0;
}
Roy and Profile picture
#include<stdio.h>
int main(){
int h,s,sp;
scanf("%d%d%d",&h,&s,&sp);
if(h>50 && s>60 && sp>100)
printf("10");
else if(h>50 && s>60)
printf("9");
else if(s>60 && sp>100)
printf("8");
else if(h>50 && sp>100)
printf("7");
else if(h<=50 && s<=60 && sp<=100)
printf("5");
else
printf("6");
return 0;
}
count divisers
#include<stdio.h>
int main(){
int l,r,k,count=0;
scanf("%d%d%d",&l,&r,&k);
for(int i=l;i<=r;i++)
if(i%k==0)
count++;
printf("%d",count);
return 0;
}
small factorials
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int a, fact=1;
scanf("%d",&a);
for(int j=1;j<=a;j++)
fact=fact*j;
printf("%d\n",fact);
}
return 0;
}
power of a number
#include<stdio.h>
#include<math.h>
int main(){
int x,y,m,a;
scanf("%d%d%d",&x,&y,&m);
a=pow(x,y);
printf("%d",a%m);
return 0;
}
Add digits
#include<stdio.h>
int digSum(int n)
{
int sum = 0;
while(n > 0 || sum > 9)
{
if(n == 0)
{
n = sum;
sum = 0;
}
sum += n % 10;
n /= 10;
}
return sum;
}
int main()
{
int n;
scanf("%d",&n);
printf("%d",digSum(n));
return 0;
}
--------------------------------------------------------------
sum of the given numbers
#include<stdio.h>
#include<math.h>
int main(){
int n,count=0;
scanf("%d",&n);
for(int i=1;i<=n;i++){
int a,b;
scanf("%d%d",&a,&b);
printf("%d\n",a+b);
}
}
int main(){
int n,count=0;
scanf("%d",&n);
for(int i=1;i<=n;i++){
int a,b;
scanf("%d%d",&a,&b);
printf("%d\n",a+b);
}
}
perfect square root or not
#include<stdio.h>
#include<math.h>
int main(){
int n,a;
scanf("%d",&n);
a=sqrt(n);
if(n==a*a)
printf("True");
else
printf("False");
return 0;
}
reverse of number
#include<stdio.h>
#include<string.h>
int main(){
int n,r;
scanf("%d",&n);
while(n){
r=n%10;
printf("%d",r);
n/=10;
}
}
largest digit
#include<stdio.h>
int main(){
int n,r,max=0;
scanf("%d",&n);
while(n){
r=n%10;
if(r>max){
max=r;
}
n=n/10;
}
printf("%d",max);
}
fibonacci or not
#include<stdio.h>
int main(){
int a=0,b=1,n,temp;
scanf("%d",&n);
for(int i=0;a<n;i++){
temp=a;
a=b;
b=temp+b;
}
if(a==n)
printf("True");
else
printf("False");
}
fibonacci
#include<stdio.h>
int main(){
int a=0,b=1,n,temp;
scanf("%d",&n);
for(int i=0;i<n;i++){
printf("%d ",a);
temp=a;
a=b;
b=temp+b;
}
}
Abundent numbers
#include<stdio.h>
#include<string.h>
int main(){
int a,i,sum;
scanf("%d",&a);
sum=0;
for (i=1;i<a;i++){
if(a%i==0){
sum+=i;
}
}
if(sum>a)
printf("True");
else
printf("False");
return 0;
}
tables
#include<stdio.h>
int main(){
int n,r;
scanf("%d%d",&n,&r);
for (int i=1;i<=r;i++){
if(i%2==0)
continue;
printf("%d x %d = %d\n",n,i,n*i);
}
return 0;
}