Skip to main content

Zoho Interview | Set 5 (On-Campus Drive)


 
 
 
#include<stdio.h>
#include<conio.h>

#define N 6

void display(int a[N][N]){
int i,j;
for(i=0;i<N;i++){
 for(j=0;j<N;j++)
  printf("%4d",a[i][j]);
 printf("\n\n");
}

}

void rotateMatrix(int a[N][N], int b[N][N]){

int i,j,temp,times,end,start;
times = 0;
end = N-1;
start = 0;
temp = N/2;
 while(times < temp){
 i = j = times;

  b[i][j++] = a[i+1][j];
  while( j < end ){
   b[i][j++] = a[i][j-1];
  }
  b[i++][j] = a[i][j-1];


  while( i < end ){
   b[i++][j] = a[i-1][j];
  }

  b[i][j--] = a[i-1][j];
  while( j > start ){
   b[i][j--] = a[i][j+1];
  }

  b[i--][j] = a[i][j+1];
  while( i > start ){
   b[i--][j] = a[i+1][j];
  }
 times++;
 end--;
 start++;
 }

}

int main(){
int a[N][N],i,j,b[N][N],k;
clrscr();

memset(b, 0, sizeof(b));

k = 1;
for(i=0;i<N;i++)
 for(j=0;j<N;j++)
  a[i][j] = k++;

display(a);
rotateMatrix(a, b);
printf("\n\nAfter the Rotate...\n\n\n");
display(b);
getch();
return 0;
}

Comments

Post a Comment

Popular posts from this blog

ORACLE 9i practice solutions

Created by BCL easyConverter SDK 3 (HTML Version)

C Questions

C Questions
C Questions

Note : All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:

void main()
{
int const * p=5; printf("%d",++(*p));
}
Answer:
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
main()
{
char s[ ]="man"; int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
Answer: mmmm
aaaa nnnn
Explanation

Zoho Interview | Set 1 (Advanced Programming Round)

Third Round: (Advanced Programming Round) Here they asked us to create a “Railway reservation system” and gave us 4 modules. The modules were:
    1. Booking
    2. Availability checking
    3. Cancellation
    4. Prepare chart
We were asked to create the modules for representing each data first and to continue with the implementation phase.

 My Solution :

#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<string.h>#include<iostream.h>#include<time.h>#include<iomanip.h>#include<fstream.h>char f[10]="f";char s[10]="s";int addr,ad,flag,f1,d,m,i,amt;float tamt; class login {public:char id[100];char pass[100];char*password;void getid(){ cout<<"Enter your id:";gets(id); password=getpass("Enter the password:");strcpy(pass,password);}void displayid(){ cout<<"Id:";puts(id); cout<<"Password:";puts(pass);}}; class detail {public:in…