How to get input number and character from user and print it as output in C++?

                                                                                C++ CODE:

                        GETTING INPUT NUMBER FROM USER AND PRINT THE NUMBER AS OUTPUT

INTRODUCTION:

                  First, write all the header files of c++. I am a variable for getting input. Then, we will open the main function in that we can use void or int main function. If we use the int main function, we have to use the return 0 statement at the end of the main function. If we use the void main function, we don't have to use the return function at the end of the main function. Because void didn't return any value, we will get the input number from the user and print it as output. Then using the cost function for print the output and can function for getting input.

 

 

CODE:

#include                  /*header file*/

#include<bits/stdc++.h>               /*header file*/

using namespace std;

int main(){                       /*opening main function*/

         int i;                                /*i is a number integer variable*/

         std::cout<<"Enter the number to be printed: "<<endl;              /* printing statement*/

         std::cin>>i;                              /* getting input from the user  */

         std::cout<<"Entered number is: "<<i<<endl;                    /* printing the number entered */

         return 0;                          /*we are using int main so we have to put return 0 at the end of the main function */

}

 

 

                                               

GETTING INPUT CHARACTER FROM USER AND PRINT THE CHARACTER  AS OUTPUT

INTRODUCTION:

                  First, write all the header files of c++. I am a variable for getting input. Then, we will open the main function in that we can use void or int main function. If we use the int main function, we have to use the return 0 statement at the end of the main function. If we use the void main function, we don't have to use the return function at the end of the main function. Because void didn't return any value, we will get the input number from the user and print it as output. Then using the cost function for print the output and can function for getting input.

 

 

CODE:

#include                  /*header file*/

#include<bits/stdc++.h>               /*header file*/

using namespace std;

int main(){                       /*opening main function*/

         char c;                                /*c is a character  variable*/

         std::cout<<"Enter the character to be printed: "<<endl;              /* printing statement*/

         std::cin>>c;                              /* getting input from the user  */

         std::cout<<"Entered character is: "<<c<<endl;                    /* printing the character entered */

         return 0;                          /*we are using int main so we have to put return 0 at the end of the main function */

 

 

 

                                                 VIDEO EXPLANATION:

https://youtu.be/e2wsLShE58A

You can see the live demo of the code on youtube

there we will explain more about the program

and we will do live coding in that. You can see how to give input and get output from the live demonstration. 

Please like and share and subscribe to our channel

Share the videos with your friends and family

support our channel.

 

 

Subscribe to our channel to see more videos and learn coding basics with a full English and live demonstration explanation.

Thank you so much & happy learning

you can ask any doubts about code or tech-related doubts in the comment section definitely. We will reply to your queries about coding.

 

 

 

Enjoyed this article? Stay informed by joining our newsletter!

Comments

You must be logged in to post a comment.

About Author