Pages

Sunday, 20 May 2012

program to find out the character is positive or negetive


98./*Write a program to find out the character is positive or negetive*/

#include<string.h>
#include<stdio.h>
#include<conio.h>
main()
{
            char string[20];
            char *ptr,c;
            clrscr();
            printf("Enter A string:");
            gets(string);
            printf("Enter a character which u wish to check:");
            scanf("%c",&c);
            ptr=strchr(string,c);
            if(ptr)
             printf("The character %c is at position:%d\n",c,ptr-string+1);
            else
             printf("The character was not found\n");
             getch();
}

OUTPUT
            Enter A string: MAHESH
            Enter a character which u wish to check : A
            The character h is at position 7

No comments:

Post a Comment