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

Answers were Sorted based on User's Feedback



Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press ..

Answer / gourav agrawal

#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();
}

Is This Answer Correct ?    6 Yes 1 No

Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press ..

Answer / anuroop khare

#include <stdio.h>
int main()
{
char input;
printf(" Please type the alphabet --> ");
scanf("%c", &input);

if ((input=='a')||(input=='A'))
printf("It represents number 1\n");
else if ((input=='b')||(input=='B'))
printf("It represents number 2\n");
else if ((input=='c')||(input=='C'))
printf("It represents number 3\n");
else if ((input=='d')||(input=='D'))
printf("It represents number 4\n");
else if ((input=='e')||(input=='E'))
printf("It represents number 5\n");
else if ((input=='f')||(input=='F'))
printf("It represents number 6\n");
else if ((input=='g')||(input=='G'))
printf("It represents number 7\n");
else if ((input=='h')||(input=='H'))
printf("It represents number 8\n");
else if ((input=='i')||(input=='I'))
printf("It represents number 9\n");
else if ((input=='j')||(input=='J'))
printf("It represents number 10\n");
else if ((input=='k')||(input=='K'))
printf("It represents number 11\n");
else if ((input=='l')||(input=='L'))
printf("It represents number 12\n");
else if ((input=='m')||(input=='M'))
printf("It represents number 13\n");
else if ((input=='n')||(input=='N'))
printf("It represents number 14\n");
else if ((input=='o')||(input=='O'))
printf("It represents number 15\n");
else if ((input=='p')||(input=='P'))
printf("It represents number 16\n");
else if ((input=='q')||(input=='Q'))
printf("It represents number 17\n");
else if ((input=='r')||(input=='R'))
printf("It represents number 18\n");
else if ((input=='s')||(input=='S'))
printf("It represents number 19\n");
else if ((input=='t')||(input=='T'))
printf("It represents number 20\n");
else if ((input=='u')||(input=='U'))
printf("It represents number 21\n");
else if ((input=='v')||(input=='V'))
printf("It represents number 22\n");
else if ((input=='w')||(input=='W'))
printf("It represents number 23\n");
else if ((input=='x')||(input=='X'))
printf("It represents number 24\n");
else if ((input=='y')||(input=='Y'))
printf("It represents number 25\n");
else if ((input=='z')||(input=='Z'))
printf("It represents number 26\n");
else
printf("you have entered a wrong alphabet");

return 0;
}

Is This Answer Correct ?    6 Yes 1 No

Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press ..

Answer / vaibhav srivastava

#include<stdio.h>
int main()
{
char c;
int i;
printf("Enter any char\t");
scanf("%c",&c);
if ( c>=65 && c<=92)

printf("%d\n",c-64);

else if( c>=97 && c<=122)

printf("%d\n",c-96);
else
printf("\n\nWrong Input\n\n");

}

Is This Answer Correct ?    3 Yes 0 No

Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press ..

Answer / abdur rab

#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 );
}

Is This Answer Correct ?    1 Yes 0 No

Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press ..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
char s;
printf("enter the character :");
scanf("%d",&s);
printf("\n here CAPITAL and SMALL letters are taken as same\n");
if(s>='A'&&s<='Z')
printf("\nthis is the %dth alphabet from first",s-'A');
else if(s>='a'&&s<='z')
printf("\nthis is the %dth alphabet from first",s-'a');
else
printf("\n INVALID ALPHABET");
getch();
}


thank u

Is This Answer Correct ?    2 Yes 2 No

Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press ..

Answer / shams

#include <iostream>

using namespace std;

int main()
{
char n;
cout<<"Enter a character";
cin>>n;
int no=int(n)>=97?int(n)-96:int(n)-64;
cout<<no;
return 0;
}

Is This Answer Correct ?    1 Yes 1 No

Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press ..

Answer / nitin garg

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


int main()
{


char a;
scanf("%c",&a);
if(a>='A' && a<='Z')
a=a+32;
printf("%d",a-96);
getch();
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What are keywords c?

0 Answers  


Is r written in c?

0 Answers  


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

0 Answers  


What are runtime error?

0 Answers  


How can I send mail from within a c program?

0 Answers  






Why do we use pointer to pointer in c?

0 Answers  


What is wrong with this code such that it doesnt produce the input reversed? #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char Space = ' '; char LineOfText; float count; LineOfText = getchar(); while ((LineOfText = getchar()) != '/n'); { count = strlen(LineOfText) - 1; while (count >= 0) { putchar(LineOfText[count]); count--; } } getchar(); return 0; }

2 Answers  


code for bubble sort?

1 Answers  


what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)

0 Answers  


what is the need for main function in c?

5 Answers  


Is c++ based on c?

0 Answers  


What are pointers? What are different types of pointers?

0 Answers   Fidelity,


Categories