Brijmohan lal Sahu - Facebook
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Showing posts with label %c. Show all posts
Showing posts with label %c. Show all posts

Thursday, September 24, 2015

Program to reverse any string in C

// Program to reverse a string
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
char name[20],rev[20];
int i,len,j;

clrscr();
printf("\nEnter a string:");                                        

scanf("%s",&name);


printf("\n name entered is: %s",name);

len=strlen(name);

printf("\nLength of string is: %d",len);
i=len-1;
j=0;
while(i>=0)
{
rev[j]=name[i];
printf("\n j=%d  i= %d of %c",j,i,rev[j]);
j=j+1;
i=i-1;
}
printf("\n reverse of string is: ");
for(j=0;j<len;j++)
{
printf("%c",rev[j]);
}

getch();
}

Tuesday, December 16, 2014

Program to check given character is in upper case or lower case and convert into upper or lower case in C.

Lower Character to Upper Character codeboxc


Code Box
---------------------------------------------

/* program to Check in put character is Lower or upper case and convert them into other case */

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
char c;
clrscr();

printf("\nEnter a character :");
scanf("%c",&c);

i=c;

if(i>=97 && i<=122)
{
printf("\nEntered Character is Lower Case : %c",c);
i=i-32;
c=(char)i;  /*Explicit type conversion */
printf("\nUpper case  Character is: %c",c);

}
else if(i>=65 && i<=90)
{
printf("\nEntered Character is Upper Case : %c",c);
i=i+32;
c=(char)i;   /*Explicit type conversion */
printf("\nLower Case  Character is: %c",c);

}
else
{
printf("\nPlease enter a correct case Character");

}

getch();

}