Warning: implicit declaration of function 'toupper' [closed] - c

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 11 months ago.
Improve this question
#include<stdio.h>
int main() {
char l,u;
printf("Enter any lowercase number: ");
scanf(" %c",&l);
u = toupper(l);
printf("The uppercase number is: %c\n",u);
return 0;
}

The toupper() function is declared in the <ctype.h> header file. So you have to include that at the top.
#include <stdio.h>
#include <ctype.h>
int main() {
char l,u;
printf("Enter any lowercase number: ");
scanf(" %c",&l);
u = toupper(l);
printf("The uppercase number is: %c\n",u);
return 0;
}

Related

avarage result always 0.0 what is wrong with my code? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int n,i;
float num[100],sum=0.0,avg;
printf("please enter a number between 1-100: ");
scanf("%d",&n);
while(n<1||n>100){
printf("wrong number, enter again: ");
scanf("%d",&n);
}
for(i=0;i<n;i++){
printf("%d. number: ",i+1);
scanf("%f",&num[i]);
sum+=num[i];
}
avg=sum/n;
printf("avarage %.2f",&avg);
return 0;
}
In last printf("...", <float>) you shold not send an adress of sum. Remove &.

output is address instead of values [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i,limit,sum=0;
int a[100];
setbuf(stdout,NULL);
printf("enter the limit");
scanf("%d",&limit);
printf("enter the values");
for(i=0;i<limit;i++)
{
scanf("%d",&a[limit]);
}
for(i=0;i<limit;i++)
{
sum=sum+a[i];
}
printf("the sum is : %d",sum);
return 0;
}
Output:
enter the limit3
enter the values3
3
3
the sum is : 19265880
The actual output should be 9
for(i=0;i<limit;i++)
{
scanf("%d",&a[limit]); //replace limit with i
}
You can see that scanf is reading into the array a[limit] instead of a[i]. This is causing the issue.

How to read a value with scanf and store it in a variable which was allocated dynamically in C? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
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.
Improve this question
Why this code isn't working? After entering the value, program crashes.
I'm just learning programming btw.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int* p;
p=(int*)malloc(sizeof(int));
printf("Enter a value : \n");
scanf("%d", *p);
printf("%d", *p);
}
scanf should have address, not value.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int* p;
p=(int*)malloc(sizeof(int));
printf("Enter a value : \n");
scanf("%d", p);
printf("%d", *p);
free(p); // should free manually
}

C - Warning while compiling simple program [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
Im receiving warnings like this "warning: array subscript has type 'char' [-Wchar-subscripts]" in lines 11, 12 and 15. Whats wrong with my code?
#include <stdio.h>
#include <ctype.h>
int main()
{
char s[1000], i, d, a;
printf("Enter a string: ");
fgets(s, 1000, stdin );
for(i = 0; s[i] != '\0'; i++){
if (isalpha(s[i])){
a++;
}
if (isdigit(s[i])){
d++;
}
}
printf("Number of digits: %d ... Number of letters: %d ", d, a);
return 0;
}

Why it doesn't work ( C Lang in Dev C++ ) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Please tell me, what is wrong here,it compiles but console crashes when i enter the number. I don't know what to write next, i will just write something to make my post possible.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{
unsigned int i,l,p,w;
printf("Enter natural number excluding 0: ");
scanf("%d",l);
p = 1;
for(i=1;i<=l;i++)
{
p=p*i;
}
w=p;
printf("\nFactorial of entered number %d",w);
return 0;
}
scanf("%d",l); you need to insert the address of l, which is &l.
You should also use %u for unsigned ints, not %d.

Resources