write a c program for print your name .but,your name may be
small
letter mean print a capital letter or your name may be
capital
letter mean print a small letter .example
\\enter ur name :
sankar
The name is: SANKAR
(or)
enter your name:SAnkar
The name is:saNKAR

Answers were Sorted based on User's Feedback



write a c program for print your name .but,your name may be small letter mean print a capital let..

Answer / vadivelt

#include<stdio.h>
#include<conio.h>
void LowrUprCase(char *ptr);
int main()
{
char ptr[100];
printf("ENTER THE NAME:\n");
gets(ptr);
LowrUprCase(ptr);
printf("\nOUTPUT: %s \n",ptr);
getch();
}

void LowrUprCase(char *ptr)
{
while(*ptr != '\0')
{
if(*ptr >= 97 && *ptr <= 122)
{
*ptr = *ptr - 32;
}

else if(*ptr >= 65 && *ptr <= 90)
{
*ptr = *ptr + 32;
}
ptr++;
}
}

Is This Answer Correct ?    9 Yes 3 No

write a c program for print your name .but,your name may be small letter mean print a capital let..

Answer / sandy880

#include<stdio.h>
#include<conio.h>
#define MAX 15

void main()
{
char arr[MAX];
int i;
clrscr();
printf("Enter your name:");
scanf("%s",arr);

for(i=0;arr[i]!='\0';i++)
{
if(arr[i]>=65&&arr[i]<=90)
{
arr[i]=arr[i]+32;

}
else if(arr[i]>=97&&arr[i]<=122)
{
arr[i]=arr[i]-32;
}

}
printf("output:%s",arr);
getch();
}

Is This Answer Correct ?    6 Yes 3 No

write a c program for print your name .but,your name may be small letter mean print a capital let..

Answer / vishnu nayak

#include<stdio.h>
#include<conio.h>
#include<string.h>

int main()
{
const char *ptr;
char *temp;
int count =0;
ptr = (char*) malloc(sizeof(char)*30);
temp = (char*) malloc(sizeof(char)*30);
printf("enter the string \n");
gets(ptr);
while(*ptr != '\0')
{
if(*ptr >=65 && *ptr <= 90)
{
*temp = (*ptr)+32;
temp++;
ptr++;
}
else if(*ptr >= 97 && *ptr <= 122)
{
*temp = (*ptr)- 32;
temp++;
ptr++;
}
else
{
*temp = *ptr;
ptr++;
temp++;
}
count++;
}
*temp = '\0';
temp = temp - count;
puts(temp);

free(temp);
free(ptr);

//getch();
}

Is This Answer Correct ?    3 Yes 2 No

write a c program for print your name .but,your name may be small letter mean print a capital let..

Answer / rakesh ranjan

#include<conio.h>
#include<stdio.h>
void main()
{
char str[20],i;
printf("enter your name:");
scanf("%s",str);
for(i=0;str[i]!='\0';i++)
{
if(str[i]<=91)
str[i]+=32;
else
str[i]-=32;
printf("%c",str[i]) ;
}
getch();
}

Is This Answer Correct ?    2 Yes 1 No

write a c program for print your name .but,your name may be small letter mean print a capital let..

Answer / vadivelt

Hi all,

In my post, Answer #1 please change the statement in if
condition from *ptr <= 96 to *ptr <= 90

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More C Interview Questions

number of times a digit is present in a number

0 Answers  


what is the need for main function in c?

5 Answers  


What is the Difference between Class and Struct?

10 Answers   Motorola,


How pointer is different from array?

0 Answers  


Explain how do you sort filenames in a directory?

0 Answers  






What's wrong with "char *p; *p = malloc(10);"?

5 Answers  


typedef struct { int i:8; char c:9; float f:20; }st_temp; int getdata(st_temp *stptr) { stptr->i = 99; return stptr->i; } main() { st_temp local; int i; local.c = 'v'; local.i = 9; local.f = 23.65; printf(" %d %c %f",local.i,local.c,local.f); i = getdata(&local); printf("\n %d",i); getch(); } why there there is an error during compiling the above program?

1 Answers  


What is default value of global variable in c?

0 Answers  


When should the const modifier be used?

0 Answers  


Is there something we can do in C but not in C++? Declare variable names that are keywords in C++ but not C.

2 Answers   Infosys,


How can I sort a linked list?

0 Answers  


What is #define?

0 Answers  


Categories