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 |
write a program to swap Two numbers without using temp variable.
75 Answers EMC, Focus, GreyB, HCL, Hitech, HP, Huawei, Infosys, Mannar Company, Microsoft, Miles Software, Odessa Technologies, Satyam, TCS, Wipro,
Why is #define used?
void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..
Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer
program to get the remainder and quotant of given two numbers with out using % and / operators?
10 Answers College School Exams Tests, IBM,
Process by which one bit pattern in to another by bit wise operation is?
a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);
What is malloc() function?
What is the general form of function in c?
What do you mean by Recursion Function?
Why we use conio h in c?
Is javascript based on c?