| Back to Questions Page |
| |
| Question |
Print all the palindrome numbers.If a number is not
palindrome make it one by attaching the reverse to it.
eg:123
output:123321 (or) 12321 |
Rank |
Answer Posted By |
|
Question Submitted By :: Nithya |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | #include<stdio.h>
main()
{
int n,m;
}  |
| Santhu |
| |
| |
| Question |
Reverse the part of the number which is present from
position i to j. Print the new number.
eg:
num=789876
i=2
j=5
778986 |
Rank |
Answer Posted By |
|
Question Submitted By :: Nithya |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | #include <stdio.h>
void reverse ( int* ip_array, int st_pos, int ed_pos )
{
if ( ( ip_array ) && ( st_pos < ed_pos ) ) {
* ( ip_array + st_pos ) ^= * ( ip_array +
ed_pos ) ^= * ( ip_array + st_pos ) ^= * ( ip_array +
ed_pos );
reverse ( ip_array, ++st_pos, --ed_pos );
}
}
int main ( int argc, char* argv [] )
{
int int_array [20];
int number = 789876;
int counter = 0;
int nloop = 0;
int start_pos = 2;
int end_pos = 5;
/* split the number into an array */
while ( number ) {
int_array [ counter++ ] = number % 10;
number = number / 10;
}
/* reverse the splited array */
reverse ( int_array, 0, counter - 1 );
/* reverse for the particular position */
if ( ( start_pos < end_pos ) && ( end_pos <=
counter ) ) {
reverse ( int_array, ( start_pos - 1 ), (
end_pos - 1 ) );
number = 0;
for ( nloop = 0; nloop < counter; nloop++ )
{
number *= 10;
number += int_array [ nloop ];
}
printf ( "\n %d", number );
}
return ( 0 );
}  |
| Abdur Rab |
| |
| |
| Question |
We can draw a box in cprogram by using only one printf();&
without using graphic.h header file? |
Rank |
Answer Posted By |
|
Question Submitted By :: Pradeep |
| This Interview Question Asked @ NIIT |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("\n______________\n|______________|");
getch();
}
output:
______________
|______________|  |
| Parmjeet Kumar |
| |
| |
|
|
| |
| Question |
Write a C Programm..
we press 'a' , it shows the albhabetical number is 1, if we
press 'g' it shows the answer 7.. any can help me |
Rank |
Answer Posted By |
|
Question Submitted By :: J |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
int no;
printf("Enter the charactor:");
scanf("%c",&ch);
if(int(ch)>=65&&int(ch)<=91)
{
no=int(ch)-64;
printf("%d\n",no);
}
if(int(ch)>=97&&int(ch)<=123)
{
no=int(ch)-96;
printf("%d\n",no);
}
getch();
}  |
| Gourav Agrawal |
| |
| |
| Answer | #include <stdio.h>
int main ( int argc, char* argv [] )
{
char ch = '0';
int nvalue = 0;
while ( 1 ) {
printf ("\n Enter the alphabet or press 0
to exit :");
scanf ( "%c", &ch );
if ( ch == '0' ) break;
nvalue = ( ( (int) 'a' <= (int) ch ) && (
(int) 'z' >= (int) ch ) )
? ~( (int) 'a' - (int) ch ) + 2
: ( ( (int) 'A' <= (int) ch ) && (
(int) 'Z' >= (int) ch ) )
? ~( (int) 'A' - (int) ch ) + 2
: 0;
printf ("\n The Value :%d", nvalue );
}
return ( 0 );
}  |
| Abdur Rab |
| |
| |
|
| |
|
Back to Questions Page |