Write a program which accepts a sentence from the user and alters it as follows: Every space is replaced by *, case of all alphabets is reversed, digits are replaced by ?
#include<stdio.h>
#include<ctype.h>
#include<string.h>
void Stral(char str[])
{
int i;
// To replace space by * in sentence
for(i=0;i<=strlen(str)-1;i++)
{
if(str[i]==' ')
str[i]='*';
// To change the case of alphabets in sentence
if(islower(str[i]))
str[i]=toupper(str[i]);
else
str[i]=tolower(str[i]);
// To replace digits by ? in sentence
if(isdigit(str[i]))
str[i]='?';
}
printf("\n %s \n",str);
}
void main()
{
char str[100];
printf("\n Enter any sentence:-");
fgets(str,100,stdin);
Stral(str);
}
-
Next Write a C++ program to create a class Worker with data members as Worker_Name, No_of_Hours_worked, Pay_Rate. Write necessary member functions to calculate and display the salary of worker. (Use default value for Pay_Rate)
-
Previous Write a C program to accept dimensions length (l), breadth(b) and height(h) of a cuboids and display surface area and volume (Hint : surface area=2(lb+lh+bh ), volume=lbh )
0 Comments