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
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 |
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 |
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 |
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 |
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 |
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 |
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 |
why do some people write if(0 == x) instead of if(x == 0)?
main() { char x; while(x=0;x<=255;x++) printf("\nAscii value %d Charater %c",x,x); }
main() { clrscr(); } clrscr();
What's wrong with the call "fopen ("c:\newdir\file.dat", "r")"?
1,1,5,17,61,217,?,?.
What is meant by realloc()?
Can you tell me how to check whether a linked list is circular?
void main() { //char ch; unsigned char ch; clrscr(); for(ch =0;ch<= 127; ch++) printf(" %c= %d \t ", ch, ch); } output?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
Are bit fields portable?
main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); }
11 Answers CISOC, CitiGroup, College School Exams Tests,
Write a function that accepts two numbers,say a and b and makes bth bit of a to 0.No other bits of a should get changed.
2 Answers Scientific Atlanta, Wipro,