Can someone solve this

Write your question here.
Hello I want to know what code should I use to solve it.
the example is this : Write a complete C program that reads 3 variables.
The first variable is an integer named x. The second variable is a float named y and the third variable is a character named z.
Then, print variable x multiplied by 10. variable y divided by 2 and the next character after z (z+1).

Edit 1 : here is my code but i don't think it's true
#include <stdio.h>
Int main ()
{
Int x = 2 ;
Float y = 1.5 ;
Char z = 5 ;
Printf("%d*10",x);
Printf("%f/2",y) ;
Printf("%cz*(z+1)");
Return 0;
}
Last edited on
How about you spend some time learning how to actually program, it doesn't get much simpler than this.
Wasim232,

First I will point out that this a c++ forum, it may be hard to get any answers to c questions. That said.
1
2
3
Printf("%d*10",x);
Printf("%f/2",y) ;
Printf("%cz*(z+1)");

the %d, %f and %c are format specifiers that tell printf how to print the variables. So, the *10 is likely to give you a compile error. I am thinking the way it should read is printf("%d", x * 10); this way you are multiplying the variable not the format specifier. The same with line 2. And the last line should be printf("%c", z * (z + 1). I just noticed that your Printfs should be all lowercase letters.

I think that will work, it has been to many years since I worked with c.

If you want to read up on printf try this link http://www.cplusplus.com/reference/cstdio/printf/

As for your inputs you could use the scanf("%d", &x). The & is a reference used for regular variables (not sure what that means), but the example was for a variable of type int. Beyond that I would have to do more research.

Hope that gives you more to work with,

Andy

After I posted I noticed the z variable should be one more than you enter, therefore it should be printf("%c", z + 1).
Last edited on
Topic archived. No new replies allowed.