Thursday, June 18, 2020

WAP to input a string and check if it's last letter is number or not.

#include <stdio.h>                                                                                 
int main() {                                                         name[100] last one = length - 1 i.e 100 - 1 = 99
                                                                           name[99] gives last value         0-9 48 - 57  ( number ) char a[10];
    printf("enter");
    scanf("%s",a);
    int as = a[9];
    if (as >= 48 && as <=57){
        printf("number");
    } else{
        printf("not");
    }
    return 0;
}

No comments:

Post a Comment

pattern

55555 4444 333 22 1 #include <stdio.h> int main() {     int i,j;     for(i=5; i>=1; i--)     {         for(j=1; j<=i;...