ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
program to find magic aquare using array
 Question Submitted By :: Nithya
I also faced this Question!!     Rank Answer Posted By  
 
  Re: program to find magic aquare using array
Answer
# 1
This is the link to read something about the magic aquare. 
try it.
htp://mathworld.wolfram.com/MagicSquare.html
 
Is This Answer Correct ?    2 Yes 1 No
Anurag
 
  Re: program to find magic aquare using array
Answer
# 2
// magic square for odd numbers....

#include<stdio.h>
main()
{
        int n;
        scanf("%d",&n);
        int a[n][n],i,j;
        int row[n],col[n],dia[2]={0};
        for(i=0;i<n;i++)
        {
                row[i]=0;
                col[i]=0;
        }
                int num=1;
                int nn=n*3/2;
                for(i=0; i < n; i++)
                        for(j=0; j < n; j++)
                               
a[(j-i+nn)%n][(i*2-j+n)%n]=num++;

                for(i=0; i < n; i++)
                {       for(j=0; j < n; j++)
                        {
                                printf("%d ",a[i][j]);

                        }

                printf("\n");
                }
}
 
Is This Answer Correct ?    2 Yes 0 No
Aditya Raj
 
 
 
  Re: program to find magic aquare using array
Answer
# 3
// magic square for odd numbers....

#include<stdio.h>
main()
{
        int n;
        scanf("%d",&n);
        int a[n][n],i,j;
        int row[n],col[n],dia[2]={0};
        for(i=0;i<n;i++)
        {
                row[i]=0;
                col[i]=0;
        }
                int num=1;
                int nn=n*3/2;
                for(i=0; i < n; i++)
                        for(j=0; j < n; j++)
                               
a[(j-i+nn)%n][(i*2-j+n)%n]=num++;

                for(i=0; i < n; i++)
                {       for(j=0; j < n; j++)
                        {
                                printf("%d ",a[i][j]);

                        }

                printf("\n");
                }
}
 
Is This Answer Correct ?    0 Yes 0 No
Aditya Raj
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }  1
plz send me all data structure related programs  1
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. Microsoft14
int aaa() {printf(“Hi”);} int bbb(){printf(“hello”);} iny ccc(){printf(“bye”);} main() { int ( * ptr[3]) (); ptr[0] = aaa; ptr[1] = bbb; ptr[2] =ccc; ptr[2](); }  1
To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. Synergy2
void main() { int const * p=5; printf("%d",++(*p)); }  1
main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }  1
Find your day from your DOB? Microsoft12
main() { if ((1||0) && (0||1)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above HCL1
main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }  1
main() { char a[4]="HELL"; printf("%s",a); } Wipro1
plz send me all data structure related programs  2
main() { int c=- -2; printf("c=%d",c); }  1
main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }  1
#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }  1
How do you write a program which produces its own source code as its output?  7
main() { extern int i; i=20; printf("%d",sizeof(i)); }  1
Program to find the largest sum of contiguous integers in the array. O(n)  7
1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18. Infosys6
Write a program that find and print how many odd numbers in a binary tree  1
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com