3. Write a c program to delete the all consonants from given string.
9. Write a c program to print the string from given character.
10. Write a c program to reverse a string
11. Reverse a string using recursion in c
12. String concatenation in c without using strcat
13. How to compare two strings in c without using strcmp
14. String copy without using strcpy in c
15. Convert a string to ASCII in c
10. Write a c program to reverse a string
11. Reverse a string using recursion in c
12. String concatenation in c without using strcat
13. How to compare two strings in c without using strcmp
14. String copy without using strcpy in c
15. Convert a string to ASCII in c
53 comments:
HI..this program is not giving any output..
plz check it
You have to include the header file coz string functions are being used.
need fflush(stdin) n getchar() there.. n change into lower case right? please make a correction..
hey this programm is not returning upper case .please correct it..
This program doesn't convert into upper case while it converts only uppercase to lower case
scanf statement does not contain &
Hey! This doesn't convert lower case to upper case, it only convert upper case to lower case.please check it.
Hi ! What would be the program without using function strlen.
Hy!I think this program is not correct.Please check it once.
the correct program is this without any error:-
#include
#include
int main(){
char str[20];
int i;
printf("Enter any string->");
scanf("%s",&str);
printf("The string is->%s",str);
for(i=0;i<=strlen(str);i++){
if(str[i]>=65&&str[i]<=90)
str[i]=str[i]+32;
}
printf("\nThe string in uppercase is->%s",str);
return 0;
}
dont we have to use fflush(stdin) when we accept string????
inside the scnaf & then . it also not work.
pls check it again.
create a function to change the case of alphebet
create a function to find factorial of anumber
create a function to the area of a triangle
Guys, It will just convert from Upper case to lower case !!! everything works perfectly
Hope you don't mind, but I added to the program to do both upper and lower case.
#include
int main(void){
char str[20];//intitializes string
int i = 0;
printf("Enter any letter");//asks for a letter
scanf("%s",&str);//scans for a letter
for(i=0;i<=20;i++)//for loop that continues to the last character of the string
{
if(str[i]>=65&&str[i]<=90)//if uppercase
str[i]=str[i]+32;//adds to character to change lower case
else if(str[i]>=97&&str[i]<+122)//if lowercase
str[i]=str[i]-32;//subtracts to change to uppercase
}
printf("\nThe opposite letter is->%s\n",str);//outputs the opposite letter
return (0);
}
no problem in the code.
The statement in the final printf() should be "\nThe converted string in lower case is %s" so that the logic is correct :)
thanks boss i want this program only it works perfectly
What is the output of:
main()
{
printf(5+"Good Morning");
}
5GoodMorning
if we do string concatenation using + operator then both operands of + operator should be a string . so it make a whole string because here 5 which is an integer has been converted into string
its not working
#include
#include
#include
int main()
{
char s[20],i=0;
printf("\nEnter word : ");
scanf("%s",s);
for(i;i==0;i++)
{
if(97<=s[i]<=122)
s[i]=s[i]-32;
}
printf("\n Anwser : %s",s);
getch();
}
1st character in to upper case
This is a very good website. Just need a c prog for following design.
If n=5 then the o|p must be:
11111
12221
12321
12221
11111
there is one change
There is(strlen)rough it and take it to n[i]
Hey guys, My Qu. is "Convert the case of a given character ( i.e. upper to lower & vice versa ) ( Use getchar & putchar )", and this prog.showing 4 errors and I don't knw how to get rid of... Help me about this prog.????
Note: I must have to solve this prog.using "getchar" and "putchar"
#include
void main()
{
char ch;
getchar(ch);
if(getchar(char)(lowercase(ch)))
{
putchar((char)uppercase(ch));
}
else if(getchar((char)uppercase(ch)))
{
putchar((char)lowercase(ch));
}
}
}
you can change it again in from Lower to Upper if you subtract it again in 32 or (-32)... since the upper to lower is (+32).
Morning
simply use build in function toupper of ctype library;
why morning..?plz explain
Nice article
its just like string pointer as in if s[15]="Good Morning" then puts(s+5) will print Morning.
there should be an equal sign instead of plus (+) sign in this line else if(str[i]>=97&&str[i]<+122)//if lowercase
hi...........this program is not run
& isn,t require for scan string
scanf("%s",str); //correct
Thanks works perfectly.
we never use & when scanning array because it is already a pointer.
#include
int main()
{char ch;
scanf("%c",&ch);
if(ch>='a'&&ch<='z')
{ch=ch-'a'+'A';}
printf("%c\n",ch);}
#include
int main()
{char ch;
scanf("%c",&ch);
if(ch>='a'&&ch<='z')
{ch=ch-'a'+'A';}
printf("%c\n",ch);}
#include
int main()
{char ch;
scanf("%c",&ch);
if(ch>='a'&&ch<='z')
{ch=ch-'a'+'A';}
printf("%c\n",ch);}
#include
int getfactorial (int n);
int main()
{
int num,fact;
printf("enter a number:");
scanf("%d",&num);
fact=getfactorial(num);
printf("the factorial of %d is %d",num,fact);
return 0;
}
int getfactorial (int n)
{
int i,sum=1;
for(i=1;i<=n;i++)
sum=sum*i;
return sum;
}
write afunction"covertcase()" which converts the lower case letters in the string to uppercase where the main function displays the final string to the user? :)
678
123
049
write a c program to which will give o/p as 678394012
good
whats is 32..
hi guys This program doesn't convert into upper case lower case y bocz it depends on compilation dependent..
//Lower to Upper and Upper to Lower case.
#include
using namespace std;
int main()
{
char str[30];
int i;
printf("\n Enter any string -> ");
scanf("%s", &str);
printf("\n The given string is -> %s", str);
//int a = sizeof(str); //return the NULL character
//int b = strlen(str); //returns the size.
for (i = 0; i < strlen(str); i++)
{
if (str[i] <= 90 /*&& str[i] != '\0'*/)
{
str[i] = str[i] + 32;
}
else if (str[i] >= 65 /*&& str[i] != '\0'*/)
{
str[i] = str[i] - 32;
}
/*else if (str[i] == '\0')
{
printf("\n After the string covertion -> %s", str);
return 0;
}*/
}
printf("\n After the string covertion -> %s", str);
return 0;
}
INSTEAD OF USING strlen we can use sizeof() but need to check the null termination because it returns the actual string size. i.e 30.
I want print mixed alphabet into upper case... For example input as ahdJJSY and output as AHDJJSY
#include
#include
int main()
{
char str[100];
int i;
printf("Enter a string \n");
gets(str);
for(i=0;i='a' && str[i]<'z') putchar(str[i]-32);
else putchar(str[i]);
}
}
#include
#include
#include
int main()
{
char str[100];
int i;
printf("Enter a string \n");
gets(str);
for(i=0;i='a' && str[i]<'z') putchar(toupper(str[i]));
else putchar(str[i]);
}
}
Post a Comment