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?
 
Ad

Advertisements

Joined
Mar 3, 2021
Messages
174
Reaction score
19
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

Top