Click here to Skip to main content
15,917,793 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Write a program that carries out the following steps:


•stores a number of your choice in a variable called a
•copies the value of a into another variable called b
•displays the values currently stored in a and b using a printf() statement
•displays the values of a and b again, but this time use a++ and ++b (instead of just plain a and b) in the printf() statement.
(Note that the ++ comes After the a, and Before the b.)
•displays the values of a and b once more

What I have tried:

I have not tried anything yet as I am new to coding and am frustrated with this task.
Posted
Updated 2-Mar-17 0:53am
Comments
F-ES Sitecore 2-Mar-17 5:37am    
No-one here is going to do your homework for you. If you're struggling to understand then go over your class notes, or get a book on C, or at the very least go through some "getting started" tutorials on the web to learn the basics. Once you understand the basics this stuff should become clear to you.

That's very (very) basic stuff: use Google to find out tutorials on C language programming.
 
Share this answer
 
Stop giving excuses, this is very very basic and simple exercise to get you started with C programming.
Study and do it yourself at C Tutorial[^] , these 2 chapters will help:
1. C Variables[^]
2. C Operators[^]
 
Share this answer
 
v2
This isn't difficult: it's all the basic stuff you just covered in your lesson, I'm sure.
The first program people have to write is normally "Hello World" - so I'm sure you have already written something like this:
C++
#include <stdio.h>

int main()
    {
    printf("Hello, World!\n");
    return 0;
    }
So stop panicking, and read the instructions carefully - they are very explicit!
Start with your "Hello world" program, and change it do do each step in turn - I'll do the first one for you, and the rest are up to you:
stores a number of your choice in a variable called a

C++
#include <stdio.h>

int main()
    {
    int a;
    a = 666;
    return 0;
    }
There! Done! Was that so difficult?
Now get on and try the next one - it is just as simple!
 
Share this answer
 
We do not do your HomeWork. This is Coding 101 level, any help is doing your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900