TAB

One of the works done by our Robotics and Machine Learning division,
SELF-LEVELING QUADCOPTER
Arduino based Quadcopter.
Self-leveling is acheived by the aligning the quadcopter using the readings from the gryo as well as the accelerometer.
A four channel RC transmitter is used to control the movement of the quadcopter when in flight. Kindly subscribe to our YouTube Channel and stay tuned.

Wednesday, 27 January 2016

PRACTICE PROBLEM 2 :(24-1 to 31-1) :'L' Pattern

======================================================================== #include<stdio.h>
void main()
{
int i,j;
int r,c;
scanf("%d %d",&r,&c);
char a[r][c];
for(i=0;i<r;i++)
for(j=0;j<c;j++)
scanf(" %c",&a[i][j]);
int check=0;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
int x,y;
x=i;
y=j;
int up,right;
up=0;
right=0;
//ANALYSING
while(x>0)
{
//printf("checking up\n");
x--;
if(a[x][y]==a[i][j])
up++;
else
break;
}
x=i;
while(y<c)
{
//printf("checking right\n");
y++;
if(a[x][y]==a[i][j])
right++;
else
break;
}
//printf("%d %d",up,right);
if(up!=0 && up==right)
{
printf("Yes");
check=1;break;
}
}
if(check==1)
{break;}
}
if(check==0)
printf("No");
}

Tuesday, 26 January 2016

PRACTICE PROBLEM 2(24-1 to 31-1):COMPLEX NUMBERS

I had to forcefully format the output in the required manner.
For example it had to be +i and not +1i ..
So not much logic in this problem except for the calculation.
========================================================================


#include<stdio.h>
void add(int,int,int,int);
void sub(int,int,int,int);
void mul(int,int,int,int);
int main()
{
  int a,b,c,d;
  scanf("%d\n%d\n%d\n%d",&a,&b,&c,&d);
  add(a,b,c,d);
  sub(a,b,c,d);
  mul(a,b,c,d);

  return 0;

}
void add(int a,int b,int c,int d)
{
  if(b+d==1)
  printf("%d+i\n",a+c);
  else if(b+d==-1)
  printf("%d-i\n",a+c);
  else if(b+d>=0)
  printf("%d+%di\n",a+c,b+d);
  else
  printf("%d%di\n",a+c,b+d);
}
void sub(int a,int b,int c,int d)
{
  if(b-d==1)
  printf("%d+i",a-c);
  else if(b-d==-1)
  printf("%d-i",a-c);
  else if(b-d>=0)
  printf("%d+%di\n",a-c,b-d);
  else
  printf("%d%di\n",a-c,b-d);
}
void mul(int a,int b,int c,int d)
{
  if(a*d+b*c==1)
  printf("%d+i",a*c-b*d);
  else if(a*d+b*c==-1)
  printf("%d-i",a*c-b*d);
  else if(a*d+b*c>=0)
  printf("%d+%di",a*c-b*d,a*d+b*c);
  else
  printf("%d%di",a*c-b*d,a*d+b*c);

}

PRACTICE PROBLEM 2 -(24-1 to 31-1) : SINGULAR TO PLURAL

#include<stdio.h>
#include<string.h>
int main()
{

char s[100];
char p[100];
scanf("%s",s);
int l=strlen(s);
char last=s[l-1];
char last_two[2];
last_two[0]=s[l-2];
last_two[1]=s[l-1];
int i;
for(i = 0; s[i]; i++){
    s[i] = tolower(s[i]);
    }
strcpy(p,s);
if(strcmp(last_two,"ch")==0 || strcmp(last_two,"sh")==0 || last=='s')
{
p[l]='e';
p[l+1]='s';
p[l+2]='\0';
    }
   
else if(last=='y')
{
p[l-1]='i';
p[l]='e';
p[l+1]='s';
p[l+2]='\0';
    }
    else
    {
    p[l]='s';
}
printf("%s %s",s,p);
return 0;
}

PRACTICE PROBLEMS 2 (24-1 to 31-1) : CIRCULAR PRIMES

Please do not blindly copy/paste.Try understanding it.
For a detailed explaination :VIDEO HERE
Please let me know if i should continue making such videos where in i explain the solution.
---------------------------------------------------------------------------------------------------------------
#include<stdio.h>
#include<math.h>
int len(int);
int prime(int);
void main()
{
int N;
int i;
scanf("%d",&N);
int r=len(N);
int p=0;
for(i=1;i<=r;i++)
{
int num=N;
int j;
int le=len(N);
for(j=0;j<i;j++)
{
int rem=num%10;
num=(num/10)+(rem*pow(10,le-1));
}
int result=prime(num);
if(result==1)
p++;
}
if(p==r)
printf("Circular prime");
else
printf("Not circular prime");
}
int len(int a)
{
int l=0;
while(a>0)
{
l++;
a/=10;
}
return l;
}
int prime(int n)
{
int c=1;
int i;
for(i=2;i<n;i++)
{
if(n%i==0)
{
c=0;
break;
}
}
return c;
}

Friday, 22 January 2016

PRACTICE PROBLEM 1 (20-1 to 27-1) : SPEED OF SOUND

#include<stdio.h>
#include<math.h>
void main()
{
int t;
scanf("%d",&t);
printf("%.2f",1086*sqrt(((5*t)+297.0)/247.0));
}

PRACTICE PROBLEM 1 (20-1 to 27-1) : EMISSION STANDARDS

#include<stdio.h>
void main()
{
int P,O;
float N;
scanf("%d",&P);
scanf("%f",&N);
scanf("%d",&O);
switch(P)
{
case 1:if(O<=50000)
{
if(N<=3.4)
{
printf("Emission do not exceed permitted level of 3.4 g/mile");
}
else
{
printf("Emission exceed permitted level of 3.4 g/mile");
}
}
else
{
if(N<=1)
{
printf("Emission do not exceed permitted level of 1 g/mile");
}
else
{
printf("Emission exceed permitted level of 1 g/mile");
}
}
break;
case 2:if(O<=50000)
{
if(N<=0.31)
{
printf("Emission do not exceed permitted level of 0.31 g/mile");
}
else
{
printf("Emission exceed permitted level of 0.31 g/mile");
}
}
else
{
if(N<=0.39)
{
printf("Emission do not exceed permitted level of 0.39 g/mile");
}
else
{
printf("Emission exceed permitted level of 0.39 g/mile");
}
}
break;
case 3:if(O<=50000)
{
if(N<=0.4)
{
printf("Emission do not exceed permitted level of 0.4 g/mile");
}
else
{
printf("Emission exceed permitted level of 0.4 g/mile");
}
}
else
{
if(N<=0.5)
{
printf("Emission do not exceed permitted level of 1.0 g/mile");
}
else
{
printf("Emission exceed permitted level of 1.0 g/mile");
}
}
break;
case 4:if(O<=50000)
{
if(N<=0.25)
{
printf("Emission do not exceed permitted level of 0.25 g/mile");
}
else
{
printf("Emission exceed permitted level of 0.25 g/mile");
}
}
else
{
if(N<=0.31)
{
printf("Emission do not exceed permitted level of 0.31 g/mile");
}
else
{
printf("Emission exceed permitted level of 0.31 g/mile");
}
}
break;
}
}

PRACTICE PROBLEM 1 (20-1 to 27-1) : BAKING A BREAD

#include<stdio.h>
void main()
{
float time=0.0;
char b,s,t;
scanf("%c\n%c\n%c",&b,&s,&t);
if(b=='w')
{
time=time+6782;
if(t=='a')
{
time=time+9000;
}

}
else
{
time=8582;
if(t=='a')
{
time=time+8400;
}
}
if(s=='d')
{
time=time+(time*0.5);
}
printf("%.0f",time);

}
/*P.S.:Use a blank space instead of "\n" in input console if skillrack shows an error indicating "use standard input console"*/

Practice Problem 1 (20-1 to 27-1) : SPEED CONVERSION

#include<stdio.h>
#include<math.h>
void main()
{
int m;
float s;
scanf("%d",&m);
scanf("%f",&s);
int time;
time=m*60;
time+=(int)(s+0.5);
float fps=5280.0/time;
fps=roundf(fps*100)/100;
float mps=1609.34/time;
mps=roundf(mps*100)/100;
printf("%.2f fps\n",fps);
printf("%.2f mps",mps);
}

Practice Problem 1 (20-1 to 27-1) : WAGE

#include <stdio.h>
#include<math.h>
void main()
{
    int I,R,N;
    scanf("%d %d %d",&I,&R,&N);
    float G=0.0;
    if(N>40)
    {
        G=40*R+(N-40)*R*1.5;
    }
    else
    {
        G=R*N;
    }
    G=G-G*0.03625;
    G=roundf(G*100)/100;
    printf("%.2f",G);
 
}

SO IT BEGINS...

Practice problems for the course CSE1002 :Problem Solving with Object Oriented Programming have been uploaded on skillrack.com
Though these five simple problems have to be solved in C, the focus will migrate towards C++ further on in the course.
Best Of Luck to all for the new Semester .
And better late than never "Have A Very Prosperous Year"
-Karthik.