if we take a number as a char then can we manipulate(add,
subtract) on this number

Answers were Sorted based on User's Feedback



if we take a number as a char then can we manipulate(add, subtract) on this number..

Answer / aravind

yes.For example
#include<stdio.h>
int main()
{
int x,y;
x='A'+1;
y='B'-1;
printf("%d,%d\n",x,y);
}
It will add the Asci value of A and subtracts B, Than 62 or B will be ans for x and A or 61 will be ans for y.

Is This Answer Correct ?    8 Yes 0 No

if we take a number as a char then can we manipulate(add, subtract) on this number..

Answer / deepak garg

#include<stdio.h>
int main()
{
int x,y;
x=1+'a';
y='b'-1;
printf("%d,%d\n",x,y);
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Interview Questions

What does static variable mean in c?

0 Answers  


main() { int x=5,y=10,z=0; x=x++ + y++; y=y++ + ++x; z=x++ + ++y; printf("%d%d%d\n",x,y,z); }

1 Answers   CodeChef,


There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

1 Answers   HCL, iGate,


How do you use a pointer to a function?

0 Answers  


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

0 Answers  






write the function int countchtr(char string[],int ch);which returns the number of timesthe character ch appears in the string. for example the call countchtr("she lives in Newyork",'e') would return 3.

6 Answers  


Explain the use of bit fieild.

0 Answers  


#include<stdio.h> int f(int,int); int main() { printf("%d",f(20,1)); return 0; } int f(int n,int k) { if(n==0) return 0; else if(n%2)return f(n/2,2*k)+k; else return f(n/2,2*k)-k; } how this program is working and generating output as 9....?

1 Answers  


What are the preprocessor categories?

0 Answers  


What does c mean in standard form?

0 Answers  


what is the defrenece between structure and union

5 Answers   Aloha Technology,


what are the stages of compilation

1 Answers   Bosch,


Categories