Chapter - 12: Console Input-Output

What would be the output of the following programs:


A
Sections
1
Exercises

(a)

#include<stdio.h>
#include<ctype.h>
int main()
{
	char ch;
	ch = getchar();
	if (islower(ch))
		putchar(toupper(ch));
	else
		putchar(tolower(ch));
	return 0;
}

Output: If the upper case letter is entered so lower case of it will be printed otherwise is the lower case is entered so uppercase will be printed.


(b)

#include<stdio.h>
int main()
{
	int i = 2;
	float f = 2.5367;
	char str[] = "Life is like that";
	printf("\n%4d\t%3.3f\t%4s", i, f, str);

	return 0;
}

Output:   2    2.537   Life is like that


(c)

#include<stdio.h>
int main()
{
	printf("More often than \b\b not \rthe person who \
 wins is the one who thinks he can!");

	return 0;
}

Output: the person who wins is the one who thinks he can!


(d)

#include<conio.h>
char p[] = "The sixth sick sheikh's sixth ship is sick";
int main()
{
	int i = 0;
	while (p[i] != '\0')
	{
		putch(p[i]);
		i++;
	}

	return 0;
}

Output: The sixth sick sheikh's sixth ship is sick


© 2021 Garbage Valuegarbage value logo