What is the value of integer variable b, if we find programming statement like b=printf(“ES-CS201”);ans.
Question
What is the value of integer variable b, if we find programming statement like b=printf(“ES-CS201”);ans.
Solution
In C programming, the printf() function returns the number of characters successfully written on the output. So, if we have a statement like b=printf("ES-CS201");, the value of b would be the number of characters in the string "ES-CS201", including the hyphen.
Here are the steps to find the value of b:
- Count the number of characters in the string "ES-CS201". There are 8 characters in total.
- The printf() function will print the string "ES-CS201" and then return the number of characters it has printed.
- This returned value is then assigned to the variable
b.
So, the value of b will be 8.
Similar Questions
What will be the output of the following code snippet?1234567#include <stdio.h>int main() { int a = 5, b = 10; int result = a == b ? a + b : a - b; printf("%d", result); return 0;}
What is the output of this statement printf(“%d”, (a++)); ?Answer areaA. The value of (a + 1)B. The current value of aC. Error messageD. Garbage
When using printf, which of the following is the format specifier for an integer?
What will be the output of the following program?#include<stdio.h> int X=40; int main() { int X=20; printf("%d", X); return 0; }Select one:400Error20
What will be the output of the following C code? (Initial values: x= 7, y = 8)#include <stdio.h> void main() { float x; int y; printf("enter two numbers \n"); scanf("%f %f", &x, &y); printf("%f, %d", x, y); }
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.