What does this C program do? [closed] - c

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
#include <stdio.h>
int main(){
char c;
while((c = getchar()) != EOF){
if(c >= 'A' && c <= 'Z')
c = c - 'A' + 'a';
putchar(c);
}
return 0;
}
Came across this C code in MIT's Practical Programming in C. Can anyone explain how this program works?

The program converts any input into lower case output.
You would have recognized this yourself, if you ran it, debugged it, or just made a paper test for this.

Related

How below macro is working in c programming language? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 months ago.
Improve this question
Code:
#include <stdio.h>
#define puts "%s C preprocessor"
int main()
{
printf(puts, puts);
return 0;
}
Output:
%s C preprocessor C preprocessor
See also...
Can anyone explain me the logic behind this output?
I tried to solve it,but I didn't get the proper explanation through my friends. If anyone can explain me ,it'll be very helpful.
The macro let to (code after linker):
int main
{
printf("%s C preprocessor", "%s C preprocessor");
return 0;
}
printf works like:
The output is then
%s C preprocessor C preprocessor

Codeforces's problem 151A I've wrote this program in C language , I think it has some problem. Help me out please [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
151A codeforces link
Here is my code written in C language. It has some problem
#include<stdio.h>
#include<conio.h>
int main ()
{
int n,k,l,c,d,p,nl,np,mm,per,tl,to,sum;
scanf("%d%d%d%d%d%d%d%d",&n,&k,&l,&c,&d,&p,&nl,&np);
mm = k*l;
per = mm/nl;
tl = c*d;
to = p/np;
sum=(per,tl,to)/n;
printf("%d",sum);
return 0;
}
You have to find the minimum value among per, tl, and to and divide that with n instead of just calculating to/n, which you are currently calculating with sum=(per,tl,to)/n;. (per and tl are ignored according to the definition of the comma operator)

Can I run a for loop inside a if statement [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
Code written in c language trying to get desired output but else condition is not running
#include<stdio.h>
int main()
{
int i;
if (i <= 10)
{
for (scanf("%d", &i);i<=10;i++)
{
printf("%d\n",i);
}
}
else
{
printf("Please enter a valid number");
}
}
You are not initialized your variable named i. You must have to initialize it before using.

C string based programming code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 5 years ago.
Improve this question
Can anyone please provide me the code in c programming language of problem in which we enter "ABCD" as an input in run time and we get "ZYXW" as output and I tried to solve this using ASCII Code
Hope this will help you . Read about ascii code of character . Also you have to gain knowledge of pointer and string .
#include<stdio.h>
int main(){
char ch[20];
scanf("%s",ch);
for(const char *s = ch; *s; ++s)
putchar('Z'-(*s-'A'));
return 0;
}

Not understanding a C program [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have following C program and I am not understanding some point of this program
#include <stdio.h>
int main()
{
char ara[100];
while(NULL != gets(ara))
{
printf("%s\n", ara);
}
return 0;
}
If I input some string like Hello World, this code return me the output same as input. But, what is NULL and gets?? Are they from C library? Why their colour not changed when I compile them?
Please read description of function gets()!
This function reads string from stdin. It returns NULL if found end of line or end of file before any characters.

Resources