Simple question

Joined
Dec 5, 2021
Messages
1
Reaction score
0
Given two statements, x = 3; and y = 5 + x;, how can you build a statement
block with the two statements?
 
Joined
Mar 3, 2021
Messages
241
Reaction score
30
I'm sorry, I don't really follow the question. Blocks in C are surrounded by curly braces. You could put them inside a function block, a conditional block, or a bare block (which just narrows the scope of the statements).

C:
#include <stdio.h>

int main(int argc, char* argv[]){
    int x = 3;
    int y = 5 + x;
    printf("y = %d\n", y);
}

Code:
#include <stdio.h>


int main(int argc, char* argv[]){
    {
        int x = 3;
        int y = 5 + x;
        printf("y = %d\n", y);
    }
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top