## Answered Questions

• #### Sum of two numbers without using arithmetic operators

ex:int a=10;int b=10;int sum=a+b;without using "+" operator calculate sum

Read Best Answer

### Editorial / Best Answer

jintojos

• Member Since May-2008 | Jul 17th, 2008

void main()
{
int a=10,b=20;
while(b--) a++;
printf("Sum is :%d",a);
}

#### mukesh

• Aug 10th, 2015

Simple

```Code
void main()
{
int a=5,b=6,c;
c=a-(-b);
printf("%d",c)

}```

#### And

• Aug 28th, 2012

For two positive numbers:

int main(){
int a = 10;
int b = 10;

printf("%d",a ^ b | ((a & b)

• #### Find the binary form

Write a program to find the binary form for the given charcter input.eg:- for 'A' ASCII value is 65 and its binary form is 1000001.

#### kbjarnason

• Jul 1st, 2010

This seems a rather pointless endeavour, as the binary representation of, say, 'a' will vary with the execution character set.    For example, in EBCDIC, 'a' has a value...

#### elexpert_arka

• Aug 31st, 2009

Here is a simple code which will just get each bit of the char by AND operationint main (){    char a; int i,j;    printf("Enter a charn");    sc...

• #### difference b/w a[i] and i[a]

Is there any relation between a[i] and i[a] while using arrays..can anyone help me with this....

#### jintojos

• Jun 9th, 2008

Bath a[i] and i[a] are same.....the variable name 'a'  contains the basic address of the  array.so a[i] means base address + index 'i' and also i[a] means base address + index 'i'

#### paragmalshe

• May 29th, 2008

There is no difference in compilation perspectiveboth are internally converted as *(a+i) or *(i+a) which means the same thing

• #### C Program for pyramid

What will be the code in c to get the following output?A B C D E F G F E D C B AA B C D E F F E D C B AA B C D E E D C B AA B C D D C B AA B C C B AA B B AA A

#### Jimmy Jack

• Apr 25th, 2012

```Code#include <iostream>
#include <fstream>

void display_sequence2(int depth)
{
int output_count = 0;
for (int count = depth - 1; count >= 0; --count) {
for (int index = 0; index <= count; ++index)
std::cout << (char) ((((output_count++ == 0) || (index == 2)) ? A : a) + index) << " ";
for (int index = (count == (depth - 1)) ? count - 1 : count; index >= 0; --index) {
std::cout << (char) ((((output_count++ == 0) || (index == 2)) ? A : a) + index);
if (index > 0)
std::cout << " ";
}
}
}

int main()
{
display_sequence2(7);
}
```

#### Gaurav Bhadauria

• Oct 13th, 2011

```Codeint i, j, k;
char a[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G' };

for (i = 0; i < 7; i++) {
for (k = 0; k < 7 - i; k++)
printf("%c ", a[k]);
for (j = 7 - (i + 1); j >= 0; j--)
printf("%c ", a[j]);
printf("n");
}
```

#### jintojos

• Jun 9th, 2008

Array name is the base address of the aaray. By using this base address we can refer to the array elements. that is a[0] means "base address + 0th" element. that is array element number is the distence from the base address to the specified data

#### Joe

• Nov 20th, 2007

The relationship between an array element and the elements index number is as follows.     1. The array name by itself is a constant pointer to the first element of the a...

• #### What is the difference between structure & union?

how can we multiply this A*B without using "*" operator?

#### Alejandro Visiedo

• Mar 5th, 2016

In an "union" type, all the members are mapped to the same base address, so that the size of the type is determinated by the biggest member. In a "structure" type, each member is mapped in sequence...

#### Nitesh Raj

• Apr 22nd, 2015

Union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members. In union, one block is...

• #### C program to count numbers of positive and negative numbers

Write a C program using arrays to count the numbers of positive and negative numbers which accepts the inputs as "size of the array" & "elements of the array" and outputs as "number of negative numbers in an array are" & "numbers of positive numbers in an array are" ?

#### shweta gupta

• Jun 25th, 2014

```Code#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
cout<<"enter the size of array"<<endl;
int size,count_neg=0,count_pos=0;
cin>>size;
int a[size];
for(int i=0;i<size;i++){
cout<<"enter element of a["<<i<<"]=";
cin>>a[i];
if((a[i]>>31)==-1) count_neg++;
else count_pos++;
}
cout<<"total negative numbers "<<count_neg<<" and positive number is "<<count_pos;

return 0;
}```

#### asdasda

• Aug 10th, 2013

```Code#include<conio.h>
#include<iostream>

using namespace std;

int value(int a);

int main ()
{
int a, num, count=0;

cout<<"How many values: ";
cin>>num;

getch ();

int value(int a);

for (a=1;a<=num;a++)
{

cout<<"Enter value "<<a<<": ";
cout<<endl;
}

getch ();
return 0;
}

```

• }">

#### What will be the output of the code?#includemain(){int a=10;int b;b=a++ + 20;printf("a= %d b= %d", a, b);}

The o/p will be 11 30. Can somebody tell me how?

#### jintojos

• Jul 2nd, 2008

The variable a is incremented by one only after completing the statement b=a++ + 20;So after executing the statement b=a++ + 20 the variable b will have the value 30.Then the value of variable a is incremented that is why the out put is 11 30.

#### amma_mans80

• Nov 7th, 2007

A = 11 b=30

#### suchi kumari

• Jul 19th, 2016

What is the meaning of char far in c is not clear? Why it is used for a pointer declaration

```Codemain()
{
char far *s1,*s2;
printf("%d%d",sizeof(s1),sizeof(s2));
}```

#### kbjarnason

• Jul 1st, 2010

C has no "far" pointers, it only has pointers.Some (generally ancient) compilers, notably for DOS, did offer near, far, and huge pointers.  This was due to how DOS managed memory.Basica...

• fun(--n);
}
}

What is the output of the above program? Explain.">

0 1 2 0

#### coolquasar

• Sep 15th, 2008

It proceeds like thisfun(3)fun(2)fun(1)fun(0)fun(-1)printf("%d",n)(Here n is 0)fun(-1)printf("%d",n)(Here n is 1)fun(0)printf("%d",n)(Here n is 2)fun(1)fun(0)printf("...

#### jintojos

• Jul 2nd, 2008

The out will be just like 3 2 1 0 2 1 0 1 0 0... not sureThis is a recursive function with 2 recursive calls one at line 13 and other in at line 15.The variable 'a' initial...

#### anshuman singh

• Jun 12th, 2017

```Codeint
getMaxOf4value (int a, int b, int c, int d)
{
int count = 0;
while (a || b || c || d)
{
if (a)
a--;
if (b)
b--;
if (c)
c--;
if (d)
d--;
count++;
}
return count;
}```

#### jintojos

• May 27th, 2008

// Find The Largest Of 4 numbers (Only For Positive Numbers) #include #include void main() { int arr[4],arr2[4],i,count; clrscr(); printf("Enter The Numbers :"); for(i=0;i

#### sivaraju.sateesh

• Jul 20th, 2010

#include<stdio.h>main(){int i=65;while(i<123){if(i<91||i>96)printf("%c",i);i++;}}

#### jintojos

• Jun 15th, 2008

#include<stdio.h> #include<conio.h> void main()   {         int alphabet=65;       ...

#### shiwang

• Dec 4th, 2016

"c #include #include #include #include #include #include #include int main(){ int n,x; scanf("%d",&n); int *arr = malloc(sizeof(int) * n); for(...

#### Akanksha Suneri

• Apr 19th, 2015

"c #include #include int main() { char str[100], temp; int i, j = 0; printf(" Enter the string :"); gets(str); i = 0; j = strlen(str) - 1; whi...

#### jintojos

• Jun 16th, 2008

Header files contains pre-compiled functions.The similar functions are grouped into same header files. These functions can be used by our programs using the icludederivative. So we can use these heade...

#### uddin2000

• Sep 13th, 2006

Hi,   To include the functions which are not changed and which are useful for other functions For ex: I/O functions are included in the header file as they are not a part of your complier. So, we use header files to make our program easier to write

#### jintojos

• May 24th, 2008

// Fibnocci Series Using Recursion  #include<stdio.h>  #include<conio.h>  void fun(int,int);  int num;  void main()    { clrscr(); p...

#### jintojos

• May 24th, 2008

// Fibnocci Series Using Recursion #include #include void fun(int,int); int num; void main() { clrscr(); printf("Enter The Limit :"); scanf("%d",&num); printf("The Fibnocci Series Up To %d Is...

#### jintojos

• Jun 16th, 2008

void main() { int num1,num2,sum=0,rem; printf("Enter The Number :"); scanf("%d",&num1); num2=num1; while(num2>0) { rem=num2%10; sum+=rem*rem*rem; num...

#### Deepak kumar Prasad

• Aug 7th, 2006

The check should should be while ( n>=1) and not (n>=0)The cotrol enters into an infinite while loop.

#### jintojos

• Jun 16th, 2008

Using Video Memory We can write a string into the screen.....that is the string is directly placed into the Video memory...ExampleVideo Memory Address : 0xb0008000 pgm: void main() { int i=0; ...

#### shaanxxx

• Aug 20th, 2006

Use write system call write (1 , "XXXXXXXXXXXXXXX" , strlen("XXXXXXXXXXXXXXX" ));

#### kbjarnason

• Jul 1st, 2010

As a general rule of thumb, object pointers (as opposed to function pointers) will typically be the same size, as the relevant information - memory address - requires the same size regardless of type....

#### abhimanipal

• Jul 20th, 2009

I am sorry the 2 part of the above answer is wrong..... I confused long pointer with far pointerSIze of long pointer and char pointer will be the same

#### jintojos

• Jul 7th, 2008

before the control transfered into the called fucntion(ie. xyz()), the values in some of the registers copied into the stack(registers are : BP,SP,CS,IP,falg).also the values of the local variabl...

#### Sunil Soni

• May 5th, 2006

when the function 'abc()' calls another function 'xyz()' then first of all, current status of execution is stored in the STACK i.e. the address of current statement (Which lies in Code segment), then ...

#### RohitReddy

• Mar 12th, 2018

You can use conditional operator like this,

String result = num % 2 == 0 ? "Even" : "Odd";

#### Chris

• Oct 28th, 2017

N%2 will give you 0 for even and 1 for odd. The string gives you the address of the start of the string. So for even it prints the string starting at the first character and for odd it starts at the 6th.

#### jintojos

• Jul 7th, 2008

Far pointers are mainly used for 32 bit addressing that is the segment offset addressing. Normal pointersÂ can onLy access the memory locations which is allocated by the compiler for that program. Far...

#### mahendra

• Apr 11th, 2006

When the function is present out side the segment, it requires base address and offsetaddress. To access the function, the base and offset addersses are required to specify. This is like the far jum...

• #### What is the difference between #include <file> and #include “file”?

When writing your C program, you can include files in two ways. The first way is to surround the file you want to include with the angled brackets < and >. This method of inclusion tells the preprocessor to look for the file in the predefined default location. This predefined default location is often an INCLUDE environment variable that denotes the path to your include files. For instance,...

#### jintojos

• Jun 9th, 2008

if you used #include" filename.h" for including header files then the compiler will check only in the current directory.but if you used #include<filename.h> for including header files then the compiler will checks all directories specified in the directory options of turbo c

#### supriya ahire

• Mar 19th, 2006

hi,     #include searches the file in the specified list of directories while,    #include"file" searches the file in the current working directory as wel as in the specified list of directories.

• #### How do you redirect a standard stream?

Most operating systems, including DOS, provide a means to redirect program input and output to and from different devices. This means that rather than your program output (stdout) going to the screen; it can be redirected to a file or printer port. Similarly, your program’s input (stdin) can come from a file rather than the keyboard. In DOS, this task is accomplished using the redirection characters,...

#### abhimanipal

• Jan 30th, 2010

Another way to do this is to use the dup system call.

#### jintojos

• Jun 9th, 2008

By using the operators "" we can redirect the standard input and out streams.example : d:> jinto.exe > outputredirected                d:> jinto.exe < inputredirected