hello
I had a question that what is the meaning of function in C++.
thank you

Recommended Answers

in example:

#include <iostream>
#include <stdio.h>

void examplefunction(int a, int b, char c){
    switch (c){
        case '+': printf("%d + %d = %d\n", a,b,a+b); break;
        case '-': printf("%d - %d = %d\n", a,b,a-b); break;
        case '*': printf("%d * %d = %d\n", a,b,a*b); break;
        case '/': printf("%d / %d = %d\n", …
Jump to Post

All 2 Replies

I ask that what is the meaning of switch in C++

in example:

#include <iostream>
#include <stdio.h>

void examplefunction(int a, int b, char c){
    switch (c){
        case '+': printf("%d + %d = %d\n", a,b,a+b); break;
        case '-': printf("%d - %d = %d\n", a,b,a-b); break;
        case '*': printf("%d * %d = %d\n", a,b,a*b); break;
        case '/': printf("%d / %d = %d\n", a,b,a/b); break;
        }
    }

int main() {
    examplefunction(9,3,'+');
    examplefunction(9,3,'-');
    examplefunction(9,3,'*');
    examplefunction(9,3,'/');
    return 0;
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.