Variable in C++

by Monika Dadool 04-Sep-18

0 586


A variable can be known as a temporary container for storing information. The programmers are required different methods to store the data; variable provides different methods to work with numbers and value.
For e.g.

int q=18;
Where, q = variable name

Datatypes of Variable:

Variable have datatypes. On the base of that data types, memory allocations take place by operating system. Following are the list of datatype present in C++ programming language:

1) Character types
2) Integer types (signed)
3) Integer types (unsigned)
4) Floating-point types
5) Void type
6) Boolean type
7) Null pointer

A simple example of C++ Variable Program:

#include <iostream>
using namespace std;
int main()
{
int x= 8;
int y=9;
int result =x*y;
cout<<result;
return 0;
}

Result: 72

Share:


Comments

    Waiting for your comments

Leave a Reply

< footer class = "row footer mg-zero" > < div class = "container" > < div class = "row" >
< /div> < /div> < div class = "" > < div class = "col-md-3" > < /div> < div class = "col-md-6 text-center" > < div class = "footer-menu" > < ul > < li > < a href = "about" > About < /a> < li > < a href = "privacy-policy" > Privacy Policy < /a> < li > < a href = "disclaimer" > Disclaimer < /a> < li > < a href = "contact" > Contact < /a> < /ul> < /div> < div class = "footer-copyright" > < p > 2019 | Coding Tag. < /p> < /div> < /div> < div class = "col-md-3" > < div class = "footer-menu footer-1 mb-hide" > < ul > < li > < /li> < li > < /li> < /ul> < /div> < div class = "footer-menu footer-1" > < div class = "social-icon footer-icon" > < a target = "_blank" href = "https://www.facebook.com/codingtag/" > < i class = "fa fa-facebook" > < /i> < a target = "_blank" href = "https://twitter.com/codingtag" > < i class = "fa fa-twitter" > < /i> < a target = "_blank" href = "https://plus.google.com/u/2/111285147125546363878" > < i class = "fa fa-google-plus" > < /i> < a target = "_blank" href = "https://www.youtube.com/channel/UCgdQyLCJVf4L7XZd7nZRjzQ" > < i class = "fa fa-youtube-play" > < /i> < /div> < /div> < /div> < /div> < /div> < /footer> < div id = "toTop" > < i class = "fa fa-angle-up" > < /i> < div id = "myModal" class = "modal fade" role = "dialog" > < div class = "modal-dialog" > < div class = "modal-content br-rd" > < div class = "modal-header" > < button type = "button" class = "close" data - dismiss = "modal" > & times; < /button> < h4 class = "modal-title" > < a href = "https://www.codingtag.com/" class = "img-p" rel = "home" > < img src = "img/code-1.png" class = "img-responsive center-block" alt = "coding tag" itemprop = "logo" > < /a> < /div> < div class = "modal-body" > < div class = "row" > < div class = "col-xs-5" > < img src = "" alt = "" class = "img-responsive free-pdfimg" > < /div> < div class = "col-xs-7 newpopup-img" > < form action = "" method = "post" class = "popup-input" > < h4 > GET OUR Guide to < /h4> < div class = "int-head" > < input type = "text" id = "freepdf_title" > < /div> < span id = "getpdf_msg" > < /span> < input type = "hidden" id = "freepdf_id" > < input class = "email-field" type = "text" name = "email" id = "pdf_email" pattern = "[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" required = "" placeholder = "Enter Your Email" > < div class = "consent-wrapper-x" > < input class = "submit-1" type = "button" onclick = "getPDFmail(this.value)" value = "DOWNLOAD FOR FREE" > < /div> < /form> < /div> < /div> < /div> < /div> < /div> < /div> < div class = "clearfix" > < /div> < script src = "js/jquery.1.11.1.js" > < /script> < script src = "js/bootstrap.min.js" > < /script> < script src = "js/gen_validatorv31.js" type = "text/javascript" > < /script> < /body> < script language = 'JavaScript' type = 'text/javascript' > function refreshCaptcha() { var img = document.images['captchaimg']; img.src = img.src.substring(0, img.src.lastIndexOf("?")) + "?rand=" + Math.random() * 1000; } < /script> < script > function GetCommentBox(t, blog_id, comment_id, level) { //var title = document.getElementById("title").value; var gst_url = "ajax/ajax_blogpopup.php"; jQuery.ajax({ type: "GET", url: gst_url, data: "blog_comment=Comment Box" + "&blog_id=" + blog_id + "&comment_id=" + comment_id + "&level=" + level, success: function(data) { $('#cmt' + comment_id).html(data); $('#cmt' + comment_id).toggle("slide"); } }); } function reply_comment(t, blog_id, comment_id, level) { name = document.getElementById("name" + comment_id).value; email = document.getElementById("email" + comment_id).value; comment = document.getElementById("comment" + comment_id).value; if ((blog_id == '') || (name == '') || (comment == '') || (email == '')) { alert('All fields are mandatory.'); return false; } var gst_url = "ajax/ajax_blogpopup.php"; jQuery.ajax({ type: "GET", url: gst_url, data: "blog_comment=Comment Box" + "&blog_id=" + blog_id + "&comment_id=" + comment_id + "&level=" + level + "&name=" + name + "&email=" + email + "&comment=" + comment + "&reply_comment=Reply Comment", success: function(data) { $('#cmt' + comment_id).html(data); } }); } < /script> < script > //Scroll to top $(window).on('scroll', function() { 'use strict'; if ($(this).scrollTop() != 0) { $('#toTop').fadeIn(); } else { $('#toTop').fadeOut(); } }); $('#toTop').on('click', function() { $('body,html').animate({ scrollTop: 0 }, 500); }); < /script> < script type = "text/javascript" > function update_like(blog_id) { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("blog_like_10").innerHTML = xmlhttp.responseText; // $("#comments_list").html(response); } } xmlhttp.open("POST", "ajax/ajaxqry.php?up_com=1&blog_id=" + blog_id, true); xmlhttp.send(); } function update_comment(blog_id) { name = document.getElementById("name").value; email = document.getElementById("email").value; comment = document.getElementById("comment").value; if ((blog_id != '') && (name != '') && (comment != '') && (email != '')) { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("comments").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "ajax/ajaxqry.php?up_com=1&blog_id=" + blog_id + "&name=" + name + "&email=" + email + "&comment=" + comment, true); xmlhttp.send(); } else { alert('All fields are mandatory.'); } } function home_post(i, limit) { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("home_blogs").innerHTML = xmlhttp.responseText; // $("#comments_list").html(response); } } xmlhttp.open("GET", "ajax/ajax_home.php?i=" + i + "&limit=" + limit, true); xmlhttp.send(); } function SubscribeNow(sb) { email = document.getElementById("subscribe_email").value; checkbox = document.getElementById("check_consent").checked; if ((email.length) < 5) { alert("Please enter Email address."); return false; } if (checkbox == false) { alert("Please click on the checkbox."); return false; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("subscribe_now").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "ajax/ajaxsubscribe.php?email=" + email, true); xmlhttp.send(); } function getPDFmail(sb) { email = document.getElementById("pdf_email").value; freepdf_id = document.getElementById("freepdf_id").value; if ((email.length) < 5) { alert("Please enter Email address."); return false; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { /*$('body').append('');*/ document.getElementById("getpdf_msg").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "ajax/ajax_pdfmail.php?email=" + email + "&freepdf_id=" + freepdf_id, true); xmlhttp.send(); } var contact_message = document.getElementById('message'); if (contact_message) { contact_message.addEventListener('keyup', function(e) { //alert('aa'); var max = 500; var len = $(this).val().length; var text = document.getElementById('message').value; if (len >= max) { $('#charNum').text('You have reached the characters limit'); } else { var char = max - len; $('#charNum').text(char + ' characters left'); } if ((text.search('http') != -1) || (text.search('HTTP') != -1) || (text.search('www') != -1) || (text.search('WWW') != -1)) { alert('This character is not allowed!'); } text = text.replace(/http/g, ''); text = text.replace(/www/g, ''); text = text.replace(/HTTP/g, ''); text = text.replace(/WWW/g, ''); document.getElementById('message').value = text; }, false); } var comment_text = document.getElementById('comment'); if (comment_text) { comment_text.addEventListener('keyup', function(e) { //alert('aa'); var max = 500; var len = $(this).val().length; var text = document.getElementById('comment').value; if (len >= max) { $('#charNum').text('You have reached the characters limit'); } else { var char = max - len; $('#charNum').text(char + ' characters left'); } if ((text.search('http') != -1) || (text.search('HTTP') != -1) || (text.search('www') != -1) || (text.search('WWW') != -1)) { alert('This character is not allowed!'); } text = text.replace(/http/g, ''); text = text.replace(/www/g, ''); text = text.replace(/HTTP/g, ''); text = text.replace(/WWW/g, ''); document.getElementById('comment').value = text; }, false); } function getBlogNewsletter(blog_id) { name = document.getElementById("bpopup_name").value; email = document.getElementById("bpopup_email").value; if ((blog_id != '') && (name != '') && (email != '')) { if ((name.length) < 2) { alert("Please enter proper name."); return false; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("blogpopup_news").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "ajax/ajax_blogpopup.php?blog_popup=popup_newsletter&blog_id=" + blog_id + "&name=" + name + "&email=" + email, true); xmlhttp.send(); } else { alert('All fields are mandatory.'); } } < /script> < script > $(document).on("click", ".get-pdfid", function() { var myPDFAdd = $(this).data('id'); $(".modal-content #freepdf_id").val(myPDFAdd); var pdf_title = document.getElementById("pdf_title" + myPDFAdd).value; //var pdf_subtitle = document.getElementById("pdf_subtitle"+myPDFAdd).value; var pdf_img = document.getElementById("pdf_getimg" + myPDFAdd).value; //alert(pdf_img); $(".modal-content #freepdf_title").val(pdf_title); // $(".modal-content #freepdf_subtitle").val( pdf_subtitle ); $(".free-pdfimg").attr("src", pdf_img); }); < /script> < script > $(".table").wrap("
"); < /script> < script async src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" > < /script> < script > (adsbygoogle = window.adsbygoogle || []).push({}); < /script> < script type = "text/javascript" > $(window).on('load', function() { if (!sessionStorage.getItem('variable-in-c-plus-plus')) { setTimeout(function() { $('#each').modal('show'); }, 4000); sessionStorage.setItem('variable-in-c-plus-plus', 'true'); } }); < /script> < /html>