0
Pls cheke my first code and tell me what is my mistake?
https://code.sololearn.com/cIiYeP02J9jd/?ref=app https://code.sololearn.com/crt8cDst2StT/?ref=app
6 odpowiedzi
+ 3
You are very welcome, yes I am not native English speaking myself, but the positive side is we learn to code and increase our vocabulary as we go, at the same time : )
+ 6
Hello there ...
It seems you have mistaken writing C++ code in a C code. The `cout` is an output stream of C++, it is not available in C language. Use `printf` function if you want to print something to the screen in C language. Or alternatively, move the code into a new C++ code, but remember to `include <iostream>` in the C++ code if this is your choice (discard `#include <stdio.h>`).
And in the "4" code above a little correction for this line:
`cout ("b="<<b<< "\n" );`
Should be written as follows, notice the removal of parentheses and use of `<<` (insertion) operator :
`cout << "b=" << b << "\n" ;`
Please confirm for any uncertainty, I am here to help.
P.S. Reference for `printf` function:
http://www.cplusplus.com/reference/cstdio/printf/
Hth, cmiiw
+ 6
Hello ... sorry for delays ...
Alright, seems like I was a bit unclear in my previous suggestion - I just visited your profile and see you are starting out with C, not C++.
I see you updated your code, and tried to use `printf` function, understand since it's a function, we call them by their name and parentheses, which wraps the arguments to pass (if any). So just forget what I gave you before with the `cout` and << operator because we're using C language.
Fix for code "4" and "2" are similar, all we need is just call `printf` function with the format specifier and values to print, all wrapped within parentheses.
● In code "4"
printf("b = %d\n", b);
● In code "2"
printf("a = %d\n", a);
Syntax:
printf("format-specifier", argument-list)
format-specifier is a string that specifies how the values in argument-list are supposed to be printed. I suggest you to read the reference linked in my previous response for further details about printf function.
You are welcome for any further enquiries : )
+ 1
Tnx for your helping.I'm still getting warning but I don't know why.
+ 1
Thank u so much.Iam so happy bcz of your help!I feel like Iam conquered a mountain.
+ 1
Acually Iam not native speaker so it is a little hard to learn code in english.