Conversion from uppercase to lower
case using c program
#include<stdio.h>
#include<string.h>
#include<string.h>
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 lower case is->%s",str);
return 0;
}
County String
#include <stdio.h>
int isvowel(char chk);
int main(){
char text[1000], chk;
int count;
count = 0;
while((text[count] = getchar()) != '\n')
count++;
text[count] = '\0';
count = 0;
while ((chk = text[count]) != '\0'){
if (isvowel(chk)){
if((chk = text[++count])
&& isvowel(chk)){
putchar(text[count -1]);
putchar(text[count]);
putchar('\n');
}
}
else
++count;
}
return 0;
}
int isvowel(char chk){
if(chk == 'a' || chk == 'e' || chk == 'i' || chk == 'o' || chk == 'u')
return 1;
return 0;
}
Diamond Design
#include <stdio.h>
int main()
{
int n, c, k, space = 1;
printf("Enter
number of rows\n");
scanf("%d", &n);
space = n - 1;
for (k = 1; k <=
n; k++)
{
for (c = 1; c <= space; c++)
printf("
");
space--;
for (c = 1; c <=
2*k-1; c++)
printf("*");
printf("\n");
}
space = 1;
for (k = 1; k <= n
- 1; k++)
{
for (c = 1; c <= space; c++)
printf("
");
space++;
for (c = 1 ; c <=
2*(n-k)-1; c++)
printf("*");
printf("\n");
}
return 0;
}
0 comments:
Post a Comment