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 |
Hi Every one...........I have been selected for the SBI Clerk. But i m one month Pregnanat. So anyone please suggest me, is they take any objection on my joining .
4 Answers State Bank Of India SBI,
Is it possible to have a function as a parameter in another function?
How to write a C program to determine the smallest among three nos using conditional operator?
What is the use of header files?
Is the C language is the portable language...If yes...Then Why...and if not then what is problem so it is not a Portable language..???
What's a good way to check for "close enough" floating-point equality?
What is the purpose of sprintf() function?
whether itis a structured language?
what do you mean by inline function in C?
A MobileNumber is a VIP number if it satisfy the following conditions. The operator should be Vodafone. Atleast one 0 (Zero) should be exist in mobile number. The number should not end with 8. The single digit sum of all the digits in the number should be equal to 9. For example if the number is 9876543210, the sum is 9+8+7+...+1+0 = 45. Sum of 4+5 = 9. Write a method: private boolean isVIPMobileNumber(String mobileNum, String operator) mobileNum phone number operator mobile operator as bsnl, Vodafone
Is both getch() and getchar() functions are similar? if it is similar means why these two functions are used for same usage? if it is not similar means what is the difference?
What is a far pointer?What is the utility?