Character Data Types in C

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

// Program for character data type
#include<stdio.h>
#include<conio.h>
int main()
{
       char ch;
        system("cls");
        printf("Enter a character in Upper case ");
        scanf("%c",&ch);
       // printf("Lower to Upper %c",(ch-32)); 
       printf("Upper to Lower %c",(ch+32)); 
        

    // system("cls");
    //  char ch;
    //  printf("Enter a character");
    //  scanf("%c",&ch);
    // printf("Character value is %c and Ascii value is %d",ch,ch);
    return 0;
}

Program 2

// Program for read password
#include<stdio.h>
#include<conio.h>
int main()
{
    system("cls");
    char ch1,ch2,ch3,ch4;
    char u1,u2,u3,u4;
    printf("\n User Name: ");
     u1=getche();
     u2=getche();
     u3=getche();
     u4=getche();
     getch();
    printf("\nPassword: ");
    ch1=getch();
    printf("*");
    ch2=getch();
    printf("*");
    ch3=getch();
    printf("*");
    ch4=getch();
    printf("*");
    getch();
    printf("\nMy User Name is : %c%c%c%c",u1,u2,u3,u4);
    printf("\nMy Password is :%c%c%c%c",ch1,ch2,ch3,ch4);
    return 0;
}

 

Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *