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   SiteMap shows list of All Categories in this site.
Google
 
Categories >> Code-Snippets
 
 


 

Back to Questions Page
 
Question
how to return a multiple value from a function?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Wipro
I also faced this Question!!   © ALL Interview .com
Answer
You will have to use a structure or an array and then return
a pointer to the structure/array.
 
0
Krishna
 
 
Question
how to return a multiple value from a function?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Wipro
I also faced this Question!!   © ALL Interview .com
Answer
using call by refernce
 
0
Chandu
 
 
Answer
use call by refrance..-> pointers.
 
0
Shruti
 
 
 
Answer
using if else statement
for example
int fun()
{
if(cond1)
return var1;
else
return var2;

}
 
0
Vinayakkatkar
 
 
Answer
string f()
{
   return "a multiple value"; 
}

:) if this a trick question ...
 
0
Ara
 
 
Question
How to send e-mail from an ASP.NET application?
Rank Answer Posted By  
 Question Submitted By :: Swapna
This Interview Question Asked @   TCS , Infoces, Persistent, Datapoint, Radar
I also faced this Question!!   © ALL Interview .com
Answer
MailMessage message = new MailMessage ();
        message.From = <email>;
        message.To = <email>;
        message.Subject = "Scheduled Power Outage";
        message.Body = "Our servers will be down tonight.";
        SmtpMail.SmtpServer = "localhost";
        SmtpMail.Send (message);


MailMessage and SmtpMail are classes defined in the .NET 
Framework Class Library's  System.Web.Mail namespace.

Due to a security change made to ASP.NET just before it 
shipped,  you need to set SmtpMail's SmtpServer property 
to "localhost" even though "localhost" is  the default.

In addition, you must use the IIS configuration applet to 
enable localhost  (127.0.0.1) to relay messages through the 
local SMTP service.
 
2
Swapna
 
 
Answer
OR ANOTHER EASY METHOD IS TO WRITE THE pOST METHOD IN THE 
html page or design page .. may b this could be one more 
soln.????
 
0
Rakesh
 
 
Answer
protected void btnsubmit_Click(object sender, EventArgs e
{
System.Net.Mail.MailMessage msg = new
System.Net.Mail.MailMessage(txtfrom.Text, txtname.Text,
txtSubject.Text, txtmessage.Text);

        System.Net.Mail.SmtpClient mysmtp = new
SmtpClient("192.168.1.80");
        try
        {
            mysmtp.Send(msg);
            lblmsg.Text = "mail sent";
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
}
 
0
Kranthi.j
 
 
Answer
protected void btnsubmit_Click(object sender, EventArgs e
{
System.Net.Mail.MailMessage msg = new
System.Net.Mail.MailMessage(txtfrom.Text, txtname.Text,
txtSubject.Text, txtmessage.Text);

        System.Net.Mail.SmtpClient mysmtp = new
SmtpClient("192.168.1.80");
        try
        {
            mysmtp.Send(msg);
            lblmsg.Text = "mail sent";
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
}

OR

MailMessage message = new MailMessage ();
        message.From = <email>;
        message.To = <email>;
        message.Subject = "Scheduled Power Outage";
        message.Body = "Our servers will be down tonight.";
        SmtpMail.SmtpServer = "localhost";
        SmtpMail.Send (message);


MailMessage and SmtpMail are classes defined in the .NET 
Framework Class Library's  System.Web.Mail namespace.
 
0
Pragyna
 
 
Answer
Import system.net.mail

Protected sub button_click(ByVal sender as object, ByVal e
as system.EventArgs)handles button.click

dim smtp As New SmtpClient()
smtp.send(New
MailMessage(txtfrom.text,txtto.text,txtsubject.text,txtbody.text))
label.text="Message sent"
End sub
 
0
Knowledgenet
 
 
Answer
System.Web.Mail.MailMessage obMessage = new 
System.Web.Mail.MailMessage();
obMessage.To = "Receiver@gmail.com";           
obMessage.From = "sender@gmail.com";
obMessage.Subject = strSubject;
obMessage.Body = "Hi! this is the way to send mail;
obMessage.BodyFormat = HTMl;
try
   {
 SmtpMail.SmtpServer = "";
SmtpMail.Send(obMessage);
 bRet = true;
    }
catch (System.Web.HttpException exhttp)
    {
       Trace.Write("Error sending mail " + exhttp.Message);
  }
 
0
Shivani
 
 
Answer
asp.net is a web based application,so asp.net can send e-
mail from an asp.net application
 
0
Arumugam.m
 
 
Answer
mailmessage obmail = new mailmessage();
obmail.To= "Dummy@gmail.com";
obmail.from= "sender@gmail.com";
obmail.Subject="Mail sending through web";
obmail.body="Deascription";
try
{
smtp.server="";
smtp.send(obmail);
}
catch(System.Web.HttpException exhttp)
{
trace.write("error sending mail " +exhttp.message);
}
 
0
Shivani
 
 
Answer
protected void btn_submit_Click(object sender, EventArgs e)
    {
        try
        {
            string rd = "";
            MailMessage mM = new MailMessage();
            mM.From = new MailAddress(Email.Value);
            mM.To.Add("<email>");
            mM.Subject = title.Value;
            if (Radio1.Checked)
            {
                rd = Radio1.Value;
            }
            else
            {
                rd = Radio2.Value;
            }
            mM.Body = rd + "<br>" + name.Value + "<br>" +
title.value + "<br>" + Company.Value + "<br>" + Email.Value
+ "<br>" + url.Value + "<br>" + Comment.Value;
            mM.IsBodyHtml = true;
            mM.Priority = MailPriority.High;
            SmtpClient smtp = new
SmtpClient("smtp.gmail.com", 587);
            smtp.EnableSsl = true;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = new
NetworkCredential("username", "P@ssword"); //From user
credentails 
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.Send(mM);
            AlertBox("Mail Send successfully");
        }
        catch 
        {
            AlertBox("Mail Send Failed");
        }
    }
 
0
Anand
 
 
Question
how can u draw a rectangle in C
Rank Answer Posted By  
 Question Submitted By :: Sandipan
This Interview Question Asked @   Wipro , TCS, Accenture, Cognizant, Wipro, Pnb, Oracle, Sap
I also faced this Question!!   © ALL Interview .com
Answer
BY USING PRINTF AND SCANF
 
2
Vincent
 
 
Answer
Using a rectangle(int,int,int,int)function of c graphics.
 
2
Ketan Bhavsar
 
 
Answer
using include<graphic.h>
 
0
Soumya
 
 
Answer
using ASCII codes and then using goto statements
 
0
Sumit
 
 
Answer
using rectangle(int,int,int,int)
               <left,top,right,bottom>
it is a function in graphics.h
 
0
M.d.balaji
 
 
Answer
USING rectangle(int,int,int,int)
it is a function in graphics.h
 
0
M.d.balaji
 
 
Answer
including graphics.h
then initialising graphics system using initgraph
and using the function rectangle(int left,int top,int 
right,int bottom)
 
0
Sala
 
 
Answer
no answer
 
0
Guest
 
 
Answer
using rectangle(int right,int top,int left,int bottom) in 
graphics.h
 
0
Suganya
 
 
Answer
first include the graphics.h file 
thus you can use the rectangle funtion give the proper 
parameters and the wor is done
 
0
Azad
 
 
Answer
Divide by Zero.
 
0
Anonymous
 
 
Answer
BY using #include<graphics.h>
we can draw rectangle.
The syntax is rectangle(int ,int ,int ,int)
{left,top,right,bottom}
 
0
Venkat
 
 
Answer
printf("____________________");
printf("\n|\t\t|\n|\t\t|\n|\t\t|\n|\t\t|");
printf("____________________");

    by this way i think can be possible,though some 
adjustment may required...as per size of VDU.As per my 
opinion intervier asked for this answer....as C graphics is 
not so popularly used.
     Pardon me if i'm wrong & can also mail to me.
 
0
Subhradip
 
 
Answer
line(x1,y1,x2,y1)
line(x1,y2,x2,y2)
line(x1,y1,x1,y2)
line(x2,y1,x2,y2)
 
0
Venkatesh
 
 
Answer
/*  simple.c
    example 1.0
*/
#include<graphics.h>
#include<conio.h>

void main()
{
    int gd=DETECT, gm;

    initgraph(&gd, &gm, "c:\\turboc3\\bgi " );
    rectangle(200,50,350,150); 

    getch();
    closegraph();
}
 
0
Raj
 
 
Answer
/*  simple.c
    example 1.0
*/
#include<graphics.h>
#include<conio.h>

void main()
{
    int gd=DETECT, gm;

    initgraph(&gd, &gm, "c:\\turboc3\\bgi " );
    rectangle(200,50,350,150); 

    getch();
    closegraph();
}
 
0
Mahendra Microsoft
 
 
Answer
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int driver,mode;
driver=DETECT;
initgraph(&driver,&mode,"c:\\tc\\bgi");
rectangle(100,100,250,250);
getche();
closegraph();
}
 
0
Sunny Khanna
 
 
Answer
line(x1,y1,x2,y1)
line(x1,y2,x2,y2)
line(x1,y1,x1,y2)
line(x2,y1,x2,y2)

initgraph(&gd, &gm, "c:\\turboc3\\bgi " );
    rectangle(200,50,350,150);
 
0
Santosh
 
 
Answer
to use follows

rect(x1,y1.x2,y2);
 
4
Arthanari R
 
 
Answer
using turboc2 editor
 
0
Ganesh
 
 
Answer
using pen & scale
 
5
Shiju
 
 
Answer
First we insert the graphics mode into your complier,and we
use the function rectangle(); in the rectangle function we
specified the length and breath,and we also specified where
the place in screen the rectangle is drawn.
 
0
Senthilkumar
 
 
Answer
include graphics.h

rectangle(int,int,int,int)

closegraph()
 
2
Shruti
 
 
Answer
include the header file graphics.h 
use the built in function rect(x1,y1,x2,y2)
such that (x1,y1) and (x2,y2) are the coordinates
 
0
Ram Kumar
 
 
Question
How to read MS-word document in java without displaying junk
(unnecessary) data?
Rank Answer Posted By  
 Question Submitted By :: Callmevijayc
This Interview Question Asked @   Cognizent
I also faced this Question!!   © ALL Interview .com
Answer
There are lot of third party API's availbale. Please try 
below one available in Jakarta site
Apache POI - HWPF - Java API to Handle Microsoft Word Files
 
0
Nivas
 
 
Question
Given an array of characters which form a sentence of 
words, give an efficient algorithm to reverse the order of 
the words (not characters) in it. 
Rank Answer Posted By  
 Question Submitted By :: Maggy
This Interview Question Asked @   Microsoft
I also faced this Question!!   © ALL Interview .com
Answer
#include"stdio.h"
#include"stdlib.h"

int reverse(char *string, char delimiter)
{
  char *src, *dest;
  char *temp = string;

  while( *temp )
  {
    if (*temp == delimiter)
    {
      temp++;
      continue;
    }

    src=dest=temp;
    while ( (*(dest+1) != delimiter) &&
            ( *(dest+1) != '\0' )) dest++;

            //( *(dest+1) != '\n' ) &&
    temp=dest+1;
    while( dest > src )
    {
      char tmp = *dest;
      //*dest -- = *src;
      *dest = *dest-- *src;
      //*src++=tmp;
      *src = *src++ tmp;
    }
  }
  return 0;
}

int main()
{
    char name[] = "vinod kumar dhochak";
    printf("%s\n",name);
    reverse(name,' '); /* space as delimiter,Reverse Words 
*/
    printf("%s\n",name);
    reverse(name,'\n'); /* Reverse Complete Sentence */
    printf("%s\n",name);
}
 
0
Vinod Kumar
 
 
Answer
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    char str[]="rahul shandilya is going";
    
    string ans;
    int n=0;
    while(str[n]!='\0')
         n++;   
         //cout<<n;  
        bool flag=true;     
   for(int i=n-1;i>=0;i--)
   {
          if(str[i]==' ')
          {
                       int m=i+1;
                      // cout<<m<<" ";
                       string temp;
                       while(str[m]!=' ' && m<n)
                       { 
                                       temp+=str[m];
                                       m++;
                       }
                       //cout<<m<<" ";
                       if(flag)
                       {
                               ans+=temp;
                               flag=false;
                               continue;
                       }
                       if(flag==false)
                       {
                                      ans+=' ';
                                      ans+=temp;
                       }
          } 
   }
    
   cout<<ans; 
    system("pause");
    return 0;
}
//tell me if there is a batter way to do it,i dont think my 
//solution is efficent
 
0
Rahul Shandilya
 
 
Answer
/*complexity-2n..check d prog.  */

#include<iostream.h>
#include<string.h>
#include<stdio.h>


void rev_word(char str[20],int m,int n)
{
int i,l,k;
k=n-m+1;
if(k%2==0)
l=(k/2-1);
else
l=k/2;
k=n;
for(i=m;i<=m+l;i++)
{ count++;
char t=str[i];
str[i]=str[k];
str[k]=t;
k--;
}
}
int main()
{
char str[100];
int i,j=0;
cout<<"\n\nenter string:";
gets(str);

rev_word(str,0,strlen(str)-1);


for(i=0;i<=strlen(str);i++)
{    count++;
if(str[i]==' '||str[i]=='\0')
{
rev_word(str,j,i-1);
j=i;
while(str[j]==' ')
j++;
i=j;
}
}
cout<<"\n\nsentence with order of words reversed is:";
cout<<str;
return 0;
}


 
0
Raghuram.A
 
 
Answer
#include<stdio.h>
main()
{
	int i=0,j=0,start=0,end=0,len,w_len;
	char temp;
	char str[]="Papa Kehte HAIN bada naam karega";
	printf("Before reversing the words string is %s \n",str);
	len=strlen(str);
	for(i=0,j=len-1;i<j;i++,j--)
	{
		temp=str[j];
		str[j]=str[i];
		str[i]=temp;
	}
	for(i=0,j=0;str[i]!=0;)
	{
		i=j;
		for(;str[i]!=' '&& i<len;)
			i++;
		w_len=(i-j)-1;
		
		for(start=j,end=(start+w_len);start<end;start++,end--)
		{
			temp=str[start];
			str[start]=str[end];
			str[end]=temp;
		}
		j=i+1;
	}
	printf("After  reversing the words string is %s \n",str);
}
 
0
Vijay
 
 
Question
How to Connect and Insert Record to MYSQL using PHP?
Rank Answer Posted By  
 Question Submitted By :: Solidcube
I also faced this Question!!   © ALL Interview .com
Answer
$conn = mysql_connect("localhost","root","");
  mysql_select_db("database_name",$conn);  // Connection....

  if($hh){

     $res = mysql_query("insert into `table`(`all 
paramaeters of table`)values('','','')");

  }
     $res1 = mysql_query("select * from `table`"); 
 
                  // Insert Module....
 
0
Satyajit Das
 
 
Answer
<?php
//var_dump($_POST);
	//die();
$link=mysql_connect("localhost","root","");
$db=mysql_select_db("emp",$link);
$id=$_POST['id'];
$name=$_POST['name'];
$age=$_POST['age'];
$phone=$_POST['phone'];
$salary=$_POST['salary'];
$address=$_POST['address'];


$query="insert into db(id,name,age,phone,salary,address)
values
('".$id."','".$name."','".$age."','".$phone."','".$salary."'
,'".$address."')";
//echo $query;
mysql_query($query);
echo "<B></B>DATA ADDED SUCCESSFULLY<B></B>";
?>
 
4
Mukesh Bisht
 
 
Answer
To
Connect="$dblink=mysql_connect("127.0.0.1","mediamagick","mediamagick");
$db_conn=mysql_select_db("mediamagick_italy",$dblink)or
die("could not connect");"
And To Insert = "Select (Field Names) values (values to
insert )";
 
0
Sudhanshu
 
 
Answer
<?php
->connection parts-------
mysql_connect("<webser-name>","user-name","password-name");
mysql_select_db("<database-name>");
->insertion parts--------
$r=mysql_query("insert into <table-name> values(fild 
name)");
if($r)
{
print "<h1>insert successfully";
}
else
{
print"<h1>insert not successfully";
}
 
0
Anirban Paul
 
 
Question
Find your day from your DOB?
Rank Answer Posted By  
 Question Submitted By :: Solidcube
This Interview Question Asked @   Microsoft , Accenture
I also faced this Question!!   © ALL Interview .com
Answer

#include<iostream.h>
#include<conio.h>
int leap(int y)
{
if(y%4==0&&y%100!=0||y%400==0)
return 1;
else
return 0;
}
main()
{
int d,m,y,i,rem;
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
long int days=0;
clrscr();
cout<<"enter date in dd/mm/yyyy format:";
cin>>d>>m>>y;
for(i=1;i<y;i++)
if(leap(i))
days+=366;
else
days+=365;
for(i=1;i<m;i++)
if(leap(y)&&i==2)
days+=29;
else
days+=a[i-1];
days+=d;
rem=days%7;
switch(rem)
{case 1:cout<<"monday";
break;
case 2:cout<<"tuesday";
break;
case 3:cout<<"wedday";
break;
case 4:cout<<"thursday";
break;
case 5:cout<<"friday";
break;
case 6:cout<<"saturday";
break;
case 0:cout<<"sunday";

}
getch();
return 0;
}
 
0
Raghuram.A
 
 
Answer
Hey buddy wrong program....!!! 

if you check with DOB : 16/4/1985 OR 16/04/1985

its showing Friday...

But if you check then right answer should be Tuesday ...
 
0
Saurabh Shah
 
 
Answer
No..it's giving Tuesday only..U enter 16 4 1985 n press enter.
It will show Tuesday only..Logic is correct.I made a mistake
by telling to enter date in dd/mm/yyyy format..but u just
enter date in dd mm yyyy format(space between dd,mm and
yyyy)..u will get correct ans.

                                             Raghuram.A
 
0
Raghuram.a
 
 
Answer
Hi Raghu, thanks for your program.
can you try 29th of feb 1983 (29/02/1983). Actually such a 
date is not present. But gives Tuesday.
May be you like to correct it.
 
0
Abraham
 
 
Answer
Well..Abraham..I am not checking for invalid dates in that
program.
Here is the program that u want..

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

int leap(int y)
{
if(y%4==0&&y%100!=0||y%400==0)
return 1;
else
return 0;
}


int valid(int dd,int mm,int yy)
{
if(dd>31||dd<1||mm>12||mm<1||yy<0)
return 0;
if(mm<8)
if(mm%2==0&&dd>30)
return 0;
if(mm>=8)
if(mm%2!=0&&dd>30)
return 0;
if(mm==2)
{
if(yy%4==0&&dd>29)
return 0;
else
if(yy%4!=0&&dd>28)
return 0;
}
return 1;
}
main()
{
int d,m,y,i,rem;
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
long int days=0;
clrscr();
cout<<"enter date in dd m yyyy format:";
scanf("%d %d %d",&d,&m,&y);
if(!valid(d,m,y))
{
cout<<"\nInvalid date";
getch();
return 0;
}

for(i=1;i<y;i++)
if(leap(i))
days+=366;
else
days+=365;
for(i=1;i<m;i++)
if(leap(y)&&i==2)
days+=29;
else
days+=a[i-1];
days+=d;
rem=days%7;
switch(rem)
{
case 1:cout<<"monday";
break;
case 2:cout<<"tuesday";
break;
case 3:cout<<"wedday";
break;
case 4:cout<<"thursday";
break;
case 5:cout<<"friday";
break;
case 6:cout<<"saturday";
break;
case 0:cout<<"sunday";
}
getch();
return 0;
}
 
0
Raghuram.A
 
 
Answer
pleasse refer calender book....

if u feel difficult to find your day of your date of birth
call me...i will help u!
                         by prof.muthu  M.C.A PHD 
                         PH:9962940220
 
0
Prof.muthu
 
 
Answer
@Raghu..

good job.. :-)
thanks for the code.. :-)
 
0
Shruti
 
 
Answer
using date structures
 
0
Ganesh
 
 
Answer
who is this moron prof.muthu....y the hell r u writing such
nonsense...we all know to solve by ur methods..jus stop
writing such things or GO TO HELL.
 
0
Hates Prof.muthu
 
 
Answer
epidemiologist http://ygosepij.co.cc/3159.html xxpylt epidemiologist  http://ygosepij.co.cc/3159.html  http://ygosepij.co.cc/3159.html xxpylt  <a href="http://cyhusi.co.cc/131.html ">hyalwr</a>  <a href="http://cyhusi.co.cc/131.html ">hyalwr</a>
 
0
Apygcpr
 
 
Answer
<a href="http://itywyw.co.cc/blog3/1916.html ">jlejnl</a>  http://itywyw.co.cc/2125.html  <a href="http://itywyw.co.cc/blog3/1916.html ">jlejnl</a>  doctor http://itywyw.co.cc/2125.html jbnvnbh doctor  http://itywyw.co.cc/2125.html jbnvnbh
 
0
Wfiasea
 
 
Question
How to read a directory in a C program?
Rank Answer Posted By  
 Question Submitted By :: Solidcube
I also faced this Question!!   © ALL Interview .com
Answer
void main()
{
	char path[100];
	cout<<"Enter the path of directory::";
	cin.getline(path,100);
	system("cd path");
	system("dir");
} // In windows
  // For linux change dir to ls.
 
0
Rakesh
 
 
Answer
main()
{
	char path[100];
	printf("Enter the path of directory:");
	scanf("%s",path);
	system("cd path");
	system("ls");
}
 
0
Prince
 
 
Answer
please write the correct program with output...
 
                               by prof.muthu m.c.a phd etc..
                               ph:9962940220
 
0
Muthu
 
 
Question
How to access command-line arguments?
Rank Answer Posted By  
 Question Submitted By :: Solidcube
I also faced this Question!!   © ALL Interview .com
Answer
int main(int argc, char * argv[])
{
    //argc has count of no of arguments on command line.
    // argv[] contains array of strings seperated by space.
    // so argv[1] will give u, second argument, with first
    // argument being ur ./a.out(in unix)/test.exe(in win)
    // so this way u can access CL args.

    // ur code.
}
 
0
Hello
 
 
Answer
int main(int argc,char *argv[])
{
	int i;
	for(i=0;i<argc;i++)
	cout<<argv[i];
}
 
0
Rakesh
 
 
Answer
argc is nothing but Argument Count
argv is nothing Argument Vector (or) Argument Value which 
is array of Strings.

The first argument to the Command line is always the 
Program Name. 

argc contains no. of Arguments that it passed including the 
Program Name.So Leave the 1st Argument,

int i;
for(i=1;i<=argc;i++)
cout<<argv[i];
 
0
Pb
 
 
Answer
By using -->
   int main(int argc, char * argv[])

In this statement the variable argc holds the at least one 
argument of type int , the name of the file it self first 
argument and *argv[] is array of char which takes the name 
of file.......
      If any correction plz E-mail me ...
                   Bye
 
0
Padmaraj
 
 
Question
How to return multiple values from a function?
Rank Answer Posted By  
 Question Submitted By :: Solidcube
I also faced this Question!!   © ALL Interview .com
Answer
Make array of values and return the array address as long. 
Now using pointer traverse through the value.
 
0
R. Kumaran
 
 
Answer
you can return multiple values from the function by using 
mechanism  called "call-by-reference".
for example:
  
void main()
 {
    int area,*circumference;
    area=function(area,circumference);
    cout<<"the area is "<<area;
    cout<<"the circumference is"<<circumference;
 }
int function(int a,int *b)
 {
    a=12;
    int temp=a*3;
    b=&temp;
    return a;
 }

// this is just an example............


// you can also use array and return the adress of the 
array in the main and can use to traverse the entire array 
and return multiple values from function.
 
0
Splurgeop
 
 
Answer
Make array of values and return the array address as long. 
simple example:
void main()
{
 int a[10],i,n;
 int *new_value_array;
 printf("\n Enter how many number you want to enter? ");
 scanf("%d",&n);
 for(i=0;i<n;i++)
 sacnf("%d",&a[i]);
 printf("\n old value of the array is:");
 for(i=0;i<n;i++)
 printf("\t%d",a[i]);
 new_value_array = array_modify(a,n);
 printf("\n new value of the array is: \n");   
 for(i=0;i<n;i++)
 printf("\t%d",*(new_value_array+i));
 getch();
}
 int *array_modify(int a[10],int n)
{
 int i;
 for(i=0;i<n;i++)
 a[i]=a[i]*4;
 return(a);
}
 
0
Prasanta Maiti
 
 
Answer
Multiple values can be returned from a function,
using the call by refrance method.

in this method, we pass pointers as the argument to the 
funtion..
 
0
Shruti
 
 
Question
Give a oneline C expression to test whether a number is a 
power of 2?
Rank Answer Posted By  
 Question Submitted By :: Solidcube
This Interview Question Asked @   Motorola , Google
I also faced this Question!!   © ALL Interview .com
Answer
#include<stdio.h>
void main()
{
   int number;
    printf("|n enter a  number");
    scanf("%d",&number);
    int twopower(int);
   printf("\n the given number is ");
}
 int twopower(int num)
   {
       while((num & -num)==num)
          return(1);
        printf("|n yes power of two");
}
 
0
Sandhya
 
 
Answer
#define ISPOW2(x) ( (x + (x-1) ) == (x<<1 + 1) )
 
5
Carl Menezes
 
 
Answer
main()
{
int a;
scanf("%d",&a);
if((a+(a-1))==((a<<1)-1))
printf("it is powers of 2");
else
printf("not powers of 2");
}
 
0
Sathish
 
 
Answer
#include<stdio.h>

main()
{
int a;
scanf("%d",&a);
if (a&1) 
printf ("POWER off 2");
printf ("NOT power of 2");
}
 
0
Mridul
 
 
Answer
if (x & (x-1))  // false only if x is a power of 2
 
5
Dan
 
 
Answer
# include <stdio.h>

void main()
{
       int n;
       scanf("%d",&n);
       if( n & (n-1) )
           printf("Not a Power of 2");
       else
           printf("Power of 2");
}
 
0
Vadivel
 
 
Answer
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

bool isPowerOf2(int number){
	if ( number > 0 )
		return (number & (number-1)) == 0;
	
	if (number == 0)
		return false;
	
	if (isPowerOf2(-number)){
		int count=0;
		while ( !(number & 1)) {
			++count;
			number >>= 1;
		}
		if (fmod(count,2))
			return true;
		else
			return false;
	}
	return false;
}

int main(void) {
	for(int i=-1027; i<1025; ++i){
		if (isPowerOf2(i) )
			printf("%d\n", i);
	}
	
	return EXIT_SUCCESS;
}
 
0
Nmk
 
 
Answer
#include<stdio.h>

void main()
{
int a,i;
scanf("%d",&a);

for( i = 0; a != 0; a = a >> 1)
	if( a & 0x01 )
		i++;
if( i == 1 )
printf ("POWER off 2");
else
printf (" Not power of 2");
}
 
0
Raghavendra Donnur
 
 
Answer
I think
if (x & (x-1))   wont work when number is negative.
 
0
Ashutosh
 
 
Question
print numbers till we want without using loops or condition 
statements like specifically(for,do while, while swiches, 
if etc)!
Rank Answer Posted By  
 Question Submitted By :: Solidcube
I also faced this Question!!   © ALL Interview .com
Answer
simple ! 
create a loop by main()

.i.e call main(previous_num) from main. 

till break char is hit.
 
0
Grasshopper
 
 
Answer
plz explain above answer ......
 
0
Nain
 
 
Answer
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
 int i=0,n,x;
 scanf("%d",&n);
 label1:
 {
  printf("%d",i);
  i++;
  x=i<n?i:0;
  exit(x);
  continue;
 }
 getch();
}
 
0
Srividhya
 
 
Answer
main()
{
int n;
printf("enter limit:");
scanf("%i",&n);
print(n);
}

print(int n)
{
n>0?print(n-1):printf("");
printf("\n%d",n);
}
 
0
Prince
 
 
Answer
//Simple.use recursion!
#include<stdio.h>
int f(int i,int n)
{
i<=n&&printf("\t%d",i)&&f(++i,n);
return 1;
}
main()
{
f(1,100);
return 0;
}
 
0
Raghuram.A
 
 
Answer
main()
{
static int i;
printf("%d \n",i++);
main();	
}
 
0
Vijay
 
 
Answer
//To print 1-50 without using any loops or condition statement
main()
{
static int i;
printf("%d \n",i++);
(i%51)&&main();	
}
 
0
Anil
 
 
Question
print a semicolon using Cprogram without using a semicolon 
any where in the C code in ur program!!

Rank Answer Posted By  
 Question Submitted By :: Solidcube
This Interview Question Asked @   Tata-Elxsi , Vi ETrans, Tcs
I also faced this Question!!   © ALL Interview .com
Answer
void main()
{
if(printf("semicolon")){}
if(printf(getch())){}
}
 
0
Vinay_csjm
 
 
Answer
void main()
{
    while(!printf("\nHello World"))
}
 
0
Bikash Mazumdar
 
 
Answer
Answer #1 and #2 are wrong. They dont work on Turbo C. If
anybody knows the write answer please email me the code.
 
0
Ameya
 
 
Answer