Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed C language- void function help

0 votes
asked Feb 25, 2018 by anonymous
closed Feb 27, 2018
Task: Input a word and in function for every lovercase letter print capital letter and for every capital letter print lowercase letter. Example: input AuDi --> output aUdI

Can somebody help me solving my problem because this code isn't working.

#include <stdio.h>
#include<string.h>
void conv (char word);
int main(){
    char wd[50];
    printf("\n Input word:");
    gets(wd);
    conv(wd);
    return 0;
}
void conv(char word){
    int i,n=0;
    n=strlen(word);
    printf("\n New word: ");
    for(i=0;i<n;i++){
        if(word[i]>='a' && word[i]<='z'){
            printf("%c",word[i]-32);
        }else if(word[i]>='A'&& word[i]<='Z'){
            printf("%c",word[i]+32);
        }
    }
    printf("\n");
    return;
}
closed with the note: Problem solved

2 Answers

0 votes
answered Feb 26, 2018 by anonymous
Here is working code of yours.
https://onlinegdb.com/r1QQClZOz
It was minor data type mistake, argument should have been "char word[]" instead of "char word"
0 votes
answered Feb 26, 2018 by anonymous
In the int main function you have defined the character array char wd and you are passing the same,

but in your conv function you are just taking a char word as an input make it like conv(char wordd[])
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...