🔥Finding it Damn Hard to Understand C Programming? Learn to code-the right way-with interactive lessons, quizzes & challenges. Build a strong programming base; it's IMPORTANT! Try Programiz PRO for Free: bit.ly/master-c-programming
for printf, %f and %lf are both used for double, but this is a scanf function, so only %lf is used for doublem %f is for float, therefore I agree with the other comment, option c
Programiz has been my go to channel for learning C programming. You guys never fail to give amazing tutorials. Thank you team programiz!!! Very grateful 👍👍😄😄
Just started learning programming for the first time and so far, so good. About the last quiz on the tutorial, double input is represented by %lf, hence the correct answer is ("%lf", &input);
option C is the correct answer. option A is for the int data type input, option B is for the float data type input, and option D is for the char data type input. Great content, amazing explanation.
CODE TO ENTER INTEGER AND FLOAT VALUE AND SHOW OUTPUT: #include int main() { int number; float number1; printf("Enter input values: "); scanf("%d %f", &number, &number1); printf("Number = %d", number); printf(" Float = %f", number1); return 0; } ANSWER TO THE QUIZ QUESTION: Option C: scanf("%lf", &input)
WAP to take integer and foat input from the user. #include int main(){ int number1; float number2; printf("Enter the input values: "); scanf("%d %f", &number1, &number2); printf("IntNum= %d, FloatNum= %f",number1,number2); //printf(" FloatNum= %f",number2);//
#include int main(){ int number; float decimal; printf("Enter an integer and float number with spaces: "); scanf("%d %f", &number, &decimal); printf(" Your integer = %d", integer); printf(" Your decimal = %f, decimal); return0; }
You re wrong bro, it should be: #include int main() { int number; float decimal; printf("Enter an integer and float number with spaces: "); scanf("%d %f", &number, &decimal); printf(" Your integer = %d", number); printf(" Your decimal = %.2f", decimal); return 0; }
/* Program to take integer and float input from the user */ #include int main() { int value1; float value2 ; printf(" Enter the values : "); scanf("%d" "%f",&value1,&value2); printf(" The integer value entered is : " "%d",value1); printf(" The float value entered is : " "%f",value2); return 0; }
*I found this online and I don't know if it is mentioned in later chapters but it's very important so: (about reading char variables using scanf)* "Quite often I see the following problem in people’s code ( as a matter of fact, aliens don’t do that mistake :p ), when trying to input a character again and again with scanf. Usually, this happens inside a loop, but let’s see a sample code without a loop that exposes the problem." int main() { char c;
return 0; } "which gives output:" Input No.1 s c = s Input No.2 c =
Input No.3 a c = a "As you see, the input No.2 was skipped. Well not really, not at all. But the intention of the programmer is usually to get three characters from the user, which is what is happening, isn’t? Let me explain. *Think what you do, when you input. First prompt message arrives, you type s and then what? You hit enter! Enter is a character!* *As a result, first scanf will read the s. Second scanf will read the enter! That’s why, the second printf of the value of c leaves just a newline after “c=”. Then the third scanf waits for a key press. You input a and then you hit enter. a is been assigned to variable c and enter remains in the stdin buffer, ready to be read by the next scanf. If we had a fourth scanf, then it would read the enter.* However, many would think now that, “Wait a minute… I do this while reading numbers, with %d for example and I had no problem”. Correct! Why? Because %d automatically eats whitespaces and special characters. Logical, isn’t it? Whitespaces and special characters are characters, not numbers! However, %c has to interpret whitespaces and special characters as inputs, because %c reads characters 😉 . Luckily enough, the “fix to scanf to do what you intend it to do” is to leave a space before %c. That way you say to scanf to automatically eat whitespaces and special characters, like enter! So, just change scanf(“%c”, &c); to scanf(” %c”, &c); and you will be just fine. See by yourself in the code below:" int main(void) { char c; /* FIX: Leave a space before %c */
return 0; } "which outputs, what you expect:" Input No.1 s c = s Input No.2 a c = a Input No.3 m c = m "Notice that in the first scanf, there is no need for a space before %c, since it’s the first input function, thus there is no trailing newline to eat, as discussed in the comments section below my post."
Hello Padma, Love the Programming Guide!! Just wanted to ask, during the double input you didn't add " " and still it printed "Enter character :" in next line, please explain why ?
okay so i understand what you have explained so far and i decided to try it on my own, instead of double input and alphabet, i tried using name and age but i keep getting error though i used the same format
#include int main() { float integer; double decimal; printf("Enter a Number and a decimal: "); scanf("%f %lf", &integer, &decimal); printf("Your integer is = %.0f ", integer); printf("Your decimal is = %.2lf", decimal); return 0; }
My solution to question at the end of this video. Thank you. //enters integer and float input from the user. Display responses how you wish. #include int main(){ int number; float number1; printf("please enter values here: "); scanf("%d %f", &number, &number1); printf("the values you entered here are %d and %.2f", number, number1); return 0; }
#include int main() { int number; float number2; printf("Enter the number: "); scanf("%d",&number); printf("Enter the number: "); scanf("%f",&number2); printf("Number 1 is : %d ",number); printf("Number 2 is : %0.1f",number2);
6:40 // Online C compiler to run C program online #include int main(){ int number; float decimal; printf("Please enter integer and decimal values separated by strings: "); scanf("%d %f", &number, &decimal); printf(" Integer: %d", number); printf(" Decimal: %f", decimal); return 0; }
Can you help me i am using eclipse When i type the first program the two printf line in a same line in console just like enter input value age = 22 the out put is just like this can you help how to solve 2:41
#define _CRT_SECURE_NO_WARNINGS #include int main() { float age; char firstletter; printf("Enter your age and the firstletter of your name:"); scanf("%f%c", &age, &firstletter); printf("Age:%f",age); printf(" firstletter;%c", firstletter); return 0; } this was my program and it worked 🥳all thanks to you guys!
/* Program to take an integer and a float number from user. And to display them. */ #include int main() { int number1; float number2; //Taking input from user. printf("Enter an INTEGER and FLOAT number: "); scanf("%d %f", &number1, &number2); //Printing the output. printf(" Number 1 (INTEGER) = %d", number1); printf(" Number 2 (FLOAT) = %f", number2); return 0; }
PROGRAM TO TAKE INTEGER AND FLOAT INPUT FROM USER #include int main () { int number; float number 1; printf (“Enter input values:”); scanf (“%d %f”, &number, &number1); Printf (“Integer =%d”, number); Printf (“Float =%f”, number1); return 0; } End of class quiz: I picked option C. Pls correct me 🙇🏽
Answer C is the correct way to take double input where the scanf function is being used to take the variable from the user "%lf" and the format specifier is lf and the line of code reads as follows: scanf("%lf", &input);
#include int main() { int Number1; float Number2; printf("Input a number: "); scanf("%d", &Number1); printf("Enter a number: "); scanf(" %f", &Number2); printf("Number1 is: %d", Number1); printf(" Number2 is: %.2f", Number2); return 0; } And the quiz answer is C
//program to take integer and float input from the user #include int main() { int number; float Fnumber; printf("Enter the values: "); scanf("%d %f", &number, &Fnumber);
#include int main() { int number; float anotherpoint; printf("write: "); scanf("%d %f", &number, &anotherpoint); printf("Number: %d", number); printf(" NewDecimal: %f", anotherpoint); return 0; } mine I cant thank you less for this important lesson
//Program to input number and float number and display it on screen # include int main() { int number; float float_number; printf("Input the values "); scanf("%d %f, number , float_number); printf("Number = %d and Float number = %f", number, float_number); return 0; }
How do i use the scanf function that will assign it's result for many value? For instance, input the result for name, age and gmail, then return the inpuutted values.
pls can anybody help explain this code line after line. #include "main.h" 2 3 /** 4 * _strcat - concatenate two strings 5 * @dest: the string to append to 6 * @src: the string to append 7 * 8 * Description: This function appends the string pointed to by src to the 9 * string pointed to by dest, overwriting the null byte at the end of dest. 10 * 11 * Return: a pointer to the destination string dest 12 */ 13 char *_strcat(char *dest, char *src) 14 { 15 char *dest_end = dest; 16 int src_len = 0; 17 18 while (*dest_end) 19 ++dest_end; 20 21 while (src[src_len]) 22 ++src_len; 23 24 if (src + src_len < dest || dest_end + src_len < src) 25 { 26 do { 27 *dest_end++ = *src++; 28 } while (src_len--); 29 } 30 31 return (dest); 32 }
why i am getting this output for this programme #include int main(){ int Number= 5; float value= 10.9; char Character= 'G'; printf("%d ,number=15"); printf("%f, value=10.9"); printf("%c, character=G"); return 0; } output: 5 5.990000 D anything did wrong this programme
🔥Finding it Damn Hard to Understand C Programming?
Learn to code-the right way-with interactive lessons, quizzes & challenges. Build a strong programming base; it's IMPORTANT!
Try Programiz PRO for Free: bit.ly/master-c-programming
OPTION C
for printf, %f and %lf are both used for double, but this is a scanf function, so only %lf is used for doublem %f is for float, therefore I agree with the other comment, option c
the answer is option c. scanf("%lf", &input);
Programiz has been my go to channel for learning C programming. You guys never fail to give amazing tutorials. Thank you team programiz!!! Very grateful 👍👍😄😄
What are you doing now
@@mahi8862 he's hacking most popular banks games, govrement etc
Just started learning programming for the first time and so far, so good. About the last quiz on the tutorial, double input is represented by %lf, hence the correct answer is ("%lf", &input);
option C is the correct answer. option A is for the int data type input, option B is for the float data type input, and option D is for the char data type input. Great content, amazing explanation.
Answer to the question asked in the end of the video will be option C.
I agree 100%d
But it is double input, the format specifier for double is %lf, so why do you go to %f? That's format specifier for float.
@@LyricsVibe95 In scanf and related functions, %f is used for float and %lf is used for double
CODE TO ENTER INTEGER AND FLOAT VALUE AND SHOW OUTPUT:
#include
int main() {
int number;
float number1;
printf("Enter input values: ");
scanf("%d %f", &number, &number1);
printf("Number = %d", number);
printf("
Float = %f", number1);
return 0;
}
ANSWER TO THE QUIZ QUESTION:
Option C: scanf("%lf", &input)
Great tutorial. The correct way to take a double input is of answer C: scanf("%lf", &input); Thanks.
These lessons are excellent for beginners. Keep up the good work!
Its been a while I've been subscribed to this channel and my skills as a C developer has grown rapidly. Thank you for this series !!!
WAP to take integer and foat input from the user.
#include
int main(){
int number1;
float number2;
printf("Enter the input values: ");
scanf("%d %f", &number1, &number2);
printf("IntNum= %d,
FloatNum= %f",number1,number2);
//printf("
FloatNum= %f",number2);//
return 0;
}
Outpur:
number1: 20
number2: 20.35
#include
int main(void)
{
int quantity;
float price;
printf("Enter quantity and price of products:
");
scanf("%d %f", &quantity, &price);
printf("Quantity: %d, Price: %.2f
", quantity, price);
}
Multiple choice answer: C
Nice studio setup! Very professional looking and awesome content. to the point and informative.
the course is simplified and the face facilitating is encouraging to watch all the series at once lol
@Programiz is my best experience with C
#include
int main()
{
float number;
printf("Enter the values: ");
scanf("%f" , &number);
printf("number: %f" , number);
return 0;
}
#include
int main(){
int number;
float decimal;
printf("Enter an integer and float number with spaces: ");
scanf("%d %f", &number, &decimal);
printf(" Your integer = %d", integer);
printf("
Your decimal = %f, decimal);
return0;
}
You re wrong bro, it should be:
#include
int main() {
int number;
float decimal;
printf("Enter an integer and float number with spaces: ");
scanf("%d %f", &number, &decimal);
printf(" Your integer = %d", number);
printf("
Your decimal = %.2f", decimal);
return 0;
}
@@saadtalemsi5906 i think in one year he'd understand by now💀
I enjoy your lessons very much and are very helpful 👍👍👍❤❤
I'm enjoying these lessons so easy to understand
/* Program to take integer and float input from the user */
#include
int main() {
int value1;
float value2 ;
printf("
Enter the values : ");
scanf("%d" "%f",&value1,&value2);
printf("
The integer value entered is : " "%d",value1);
printf("
The float value entered is : " "%f",value2);
return 0;
}
👍
thanks this helped alot! I said %lf instead of %f thank you so much!
Why u both use %d & % f ?
@@madhusmitamahapatra5181 im sorry were you talking to me?
@@madhusmitamahapatra5181 %d for int value and %f for float value
Thank you so much for the simplicity of your lessons
Very informative! 👍👍
*I found this online and I don't know if it is mentioned in later chapters but it's very important so: (about reading char variables using scanf)*
"Quite often I see the following problem in people’s code ( as a matter of fact, aliens don’t do that mistake :p ), when trying to input a character again and again with scanf. Usually, this happens inside a loop, but let’s see a sample code without a loop that exposes the problem."
int main()
{
char c;
printf("Input No.1
");
scanf("%c", &c);
printf("c = %c
", c);
printf("Input No.2
");
scanf("%c", &c);
printf("c = %c
", c);
printf("Input No.3
");
scanf("%c", &c);
printf("c = %c
", c);
return 0;
}
"which gives output:"
Input No.1
s
c = s
Input No.2
c =
Input No.3
a
c = a
"As you see, the input No.2 was skipped. Well not really, not at all. But the intention of the programmer is usually to get three characters from the user, which is what is happening, isn’t? Let me explain. *Think what you do, when you input. First prompt message arrives, you type s and then what? You hit enter! Enter is a character!*
*As a result, first scanf will read the s. Second scanf will read the enter! That’s why, the second printf of the value of c leaves just a newline after “c=”. Then the third scanf waits for a key press. You input a and then you hit enter. a is been assigned to variable c and enter remains in the stdin buffer, ready to be read by the next scanf. If we had a fourth scanf, then it would read the enter.*
However, many would think now that, “Wait a minute… I do this while reading numbers, with %d for example and I had no problem”. Correct! Why? Because %d automatically eats whitespaces and special characters. Logical, isn’t it? Whitespaces and special characters are characters, not numbers! However, %c has to interpret whitespaces and special characters as inputs, because %c reads characters 😉 . Luckily enough, the “fix to scanf to do what you intend it to do” is to leave a space before %c. That way you say to scanf to automatically eat whitespaces and special characters, like enter! So, just change scanf(“%c”, &c); to scanf(” %c”, &c); and you will be just fine. See by yourself in the code below:"
int main(void)
{
char c;
/* FIX: Leave a space before %c */
printf("Input No.1
");
scanf("%c", &c);
printf("c = %c
", c);
printf("Input No.2
");
scanf(" %c", &c);
printf("c = %c
", c);
printf("Input No.3
");
scanf(" %c", &c);
printf("c = %c
", c);
return 0;
}
"which outputs, what you expect:"
Input No.1
s
c = s
Input No.2
a
c = a
Input No.3
m
c = m
"Notice that in the first scanf, there is no need for a space before %c, since it’s the first input function, thus there is no trailing newline to eat, as discussed in the comments section below my post."
But I did they same way but yet that no2 is being skipped
Thanks for your giving us a good guide contents.
The answer of you question is option C.
scanf("%lf", &input);
the best tutorial i have found about c language👌
Thank you for the content. it's very interesting and helpful. enjoy it very much.
Thank you so much for the video @Programiz
Keep doing all languages in same way.. thanks a lot madam 😍🥰🥰
Thanks
Hello Padma, Love the Programming Guide!!
Just wanted to ask, during the double input you didn't add "
" and still it printed "Enter character :" in next line, please explain why ?
as a first year student c programming looks so cool....don't know how long will this feeling will go on.................
Very well simplified its easy to understand
okay so i understand what you have explained so far and i decided to try it on my own, instead of double input and alphabet, i tried using name and age but i keep getting error though i used the same format
i am loving this journey of learning so informative videos:)
Expecting more and more content/vedios from you............
great
easy to understand
Good. Waiting for the next session. 😇
#include
int main() {
float integer;
double decimal;
printf("Enter a Number and a decimal: ");
scanf("%f %lf", &integer, &decimal);
printf("Your integer is = %.0f
", integer);
printf("Your decimal is = %.2lf", decimal);
return 0;
}
My solution to question at the end of this video. Thank you.
//enters integer and float input from the user. Display responses how you wish.
#include
int main(){
int number;
float number1;
printf("please enter values here: ");
scanf("%d %f", &number, &number1);
printf("the values you entered here are %d and %.2f", number, number1);
return 0;
}
include
int main() {
int number;
printf("Enter input integer: ");
scanf("%d", &number);
printf("Number: %d", number);
return 0;
}
#include
int main() {
float number;
int number1;
printf("Enter input values: ");
scanf("%f %d", &number, &number1);
printf("Float: %.3f", number);
printf("
Integer: %d", number1);
return 0;
}
Thank you , this is great! more please.
It's been awesome 😎 so far.. thanks programming crue
Your explanation was to good mam 👍
Great 👍
#include
int main()
{
int number;
float number2;
printf("Enter the number: ");
scanf("%d",&number);
printf("Enter the number: ");
scanf("%f",&number2);
printf("Number 1 is : %d
",number);
printf("Number 2 is : %0.1f",number2);
return 0;
}
The answer to the quiz is C.... Thank you ma 🙇🏾♂️
quick and sweet. I like this tutorial a lot.
6:40
// Online C compiler to run C program online
#include
int main(){
int number;
float decimal;
printf("Please enter integer and decimal values separated by strings: ");
scanf("%d %f", &number, &decimal);
printf("
Integer: %d", number);
printf("
Decimal: %f", decimal);
return 0;
}
Can you help me i am using eclipse
When i type the first program the two printf line in a same line in console just like
enter input value age = 22 the out put is just like this can you help how to solve 2:41
#define _CRT_SECURE_NO_WARNINGS
#include
int main() {
float age;
char firstletter;
printf("Enter your age and the firstletter of your name:");
scanf("%f%c", &age, &firstletter);
printf("Age:%f",age);
printf("
firstletter;%c", firstletter);
return 0;
}
this was my program and it worked 🥳all thanks to you guys!
Thank you so much!
hi programiz
I am doing well by your channel. I am not able to find character value, when i was running the prroggrram what the reason may it be .
/*
Program to take an integer and a float number from user. And to display them.
*/
#include
int main() {
int number1;
float number2;
//Taking input from user.
printf("Enter an INTEGER and FLOAT number:
");
scanf("%d %f", &number1, &number2);
//Printing the output.
printf("
Number 1 (INTEGER) = %d", number1);
printf("
Number 2 (FLOAT) = %f", number2);
return 0;
}
the answer is C.
thank you for your tutorial.
PROGRAM TO TAKE INTEGER AND FLOAT INPUT FROM USER
#include
int main () {
int number;
float number 1;
printf (“Enter input values:”);
scanf (“%d %f”, &number, &number1);
Printf (“Integer =%d”, number);
Printf (“Float =%f”, number1);
return 0;
}
End of class quiz:
I picked option C.
Pls correct me 🙇🏽
Very simplified course seen so far.
Thank you this was useful for beginner!
very clear and nice tutorial
thank you🤗🤗🤗🤗
liking this course, thanks
Answer C is the correct way to take double input where the scanf function is being used to take the variable from the user "%lf" and the format specifier is lf and the line of code reads as follows: scanf("%lf", &input);
MUCHA GRACIAS
#include
int main() {
int Number1;
float Number2;
printf("Input a number: ");
scanf("%d", &Number1);
printf("Enter a number: ");
scanf("
%f", &Number2);
printf("Number1 is: %d", Number1);
printf("
Number2 is: %.2f", Number2);
return 0;
}
And the quiz answer is C
is it not possible to write a full word on char...?
must it always have to be a letter...?
//program to take integer and float input from the user
#include
int main() {
int number;
float Fnumber;
printf("Enter the values: ");
scanf("%d %f", &number, &Fnumber);
printf("number: %d", number);
printf("
Fnumber: %f", Fnumber);
return 0;
}
#include
int main() {
int number;
float anotherpoint;
printf("write: ");
scanf("%d %f", &number, &anotherpoint);
printf("Number: %d", number);
printf("
NewDecimal: %f", anotherpoint);
return 0;
}
mine
I cant thank you less for this important lesson
thanks it helped me finding the mistake in mine
@@stellicpiano you are welcome mate
Super Explaintaion and good visual's
Finally waiting is over 👍👍👍
Why we put scanf("
%c", &...)
with this and not with printf ("enter the character value")
Code for integer and float input:
int age;
float test;
printf("enter new value:");
scanf("%d %f" , &age , &test );
printf(" new age: %d", age);
printf("new test: %f", test);
Somebody please check the correctness of this code.
Will be appreciated 👍🏻
Thanks!
The answer is option C 😊 bcoz we use %lf as format specifier for double data type
i like it when i have something to learn i love it i will able to continue watch u until my eyes inlove with u your so beatiful and awesome.
it'll be option c right?
As usual, awesome and great.
in love with your content!!
%lf is the format specifier of double input data type.
c.😁. thanks to my good teacher!
Great Video
hi guys i'm new and this was my solution
#include
int main () {
int number;
float number1;
printf("Enter integer input: ");
scanf("%d", &number);
printf("Enter float input: ");
scanf("
%f", &number1);
printf("Integer = %d", number);
printf("
Floating Number = %f", number1);
return 0;
}
and
#include
int main() {
int number;
float number1;
printf("Enter input values: ");
scanf("%d %f", &number, &number1);
printf("Integer = %d", number);
printf("
Floating Number = %f", number1);
return 0;
}
thank you for such beneficial content
// Online C compiler to run C program online
#include
int main() {
int number;
float value;
printf("Enter integer value:");
scanf("%d", &number);
printf("Enter float value:");
scanf("
%f", &value);
printf("%d", number);
printf("
%.2f", value);
return 0;
}
great one! as always!
//Program to input number and float number and display it on screen
# include
int main()
{
int number;
float float_number;
printf("Input the values
");
scanf("%d %f, number , float_number);
printf("Number = %d and Float number = %f", number, float_number);
return 0;
}
I enjoy your course
C is correct option
How do i use the scanf function that will assign it's result for many value?
For instance, input the result for name, age and gmail, then return the inpuutted values.
pls can anybody help explain this code line after line.
#include "main.h"
2
3 /**
4 * _strcat - concatenate two strings
5 * @dest: the string to append to
6 * @src: the string to append
7 *
8 * Description: This function appends the string pointed to by src to the
9 * string pointed to by dest, overwriting the null byte at the end of dest.
10 *
11 * Return: a pointer to the destination string dest
12 */
13 char *_strcat(char *dest, char *src)
14 {
15 char *dest_end = dest;
16 int src_len = 0;
17
18 while (*dest_end)
19 ++dest_end;
20
21 while (src[src_len])
22 ++src_len;
23
24 if (src + src_len < dest || dest_end + src_len < src)
25 {
26 do {
27 *dest_end++ = *src++;
28 } while (src_len--);
29 }
30
31 return (dest);
32 }
Really Helpful
The choice number C . is the correct way to take doublen input isn’t it ?
answer is c
love your content 😀
Ur just amazing madam.. very useful to us😍
same as my university beginners course.👌
very good video
(c) is the correct in given options.
thank you you helped me alot in my school exam
My answer to the quiz is option c
why i am getting this output for this programme
#include
int main(){
int Number= 5;
float value= 10.9;
char Character= 'G';
printf("%d ,number=15");
printf("%f, value=10.9");
printf("%c, character=G");
return 0;
}
output:
5
5.990000
D
anything did wrong this programme
Yeah ..! It's too good for a basic Lerner who already have should have some basics on C 😅😅
I want you as my professor omgggg 🥺🥺