कंप्यूटर प्रोग्रामिंग/वेरिएबल/सी++
दिखावट
(कंप्यूटर प्रोग्रामिंग/चर/सी++ से अनुप्रेषित)
variables.cpp
[सम्पादन | स्रोत सम्पादित करें]#include <iostream>
using namespace std;
int main()
{
cout << "Variables and Data Types\n";
int i = 1234567890;
float f = 1.2345678;
double d = 1.234567890123456;
char s[] = "string";
cout << "int: " << i << "\n";
cout << "float: " << f << "\n";
cout << "double: " << d << "\n";
cout << "string: " << s << "\n";
cout << "Constants\n";
const float pi = 3.14159;
const char c[] = "Constant";
cout << pi << "\t" << c << "\n\n";
cout << "Arithmetic Operators\n";
int a = 3;
int b = 2;
cout << "a = " << a << "\n";
cout << "b = " << b << "\n";
cout << "a + b = " << a + b << "\n";
cout << "a - b = " << a - b << "\n";
cout << "a * b = " << a * b << "\n";
cout << "a / b = " << a / b << "\n\n";
cout << "Assignment Operators\n";
a += b;
cout << "a += b is " << a << "\n";
a -= b;
cout << "a -= b is " << a << "\n";
a *= b;
cout << "a *= b is " << a << "\n";
a /= b;
cout << "a /= b is " << a << "\n\n";
cout << "User Input\n";
char username[256];
cout << "What is your name? ";
cin >> username;
cout << "Hello " << username << "!\n";
return 0;
}
कोशिश करो
[सम्पादन | स्रोत सम्पादित करें]निम्न कोड मुफ्त ऑनलाइन विकास के वातावरण में से एक में ऊपर कॉपी और पेस्ट करो या अपने खुद के कम्पाइलर/इंटरप्रेटर/आईडीई का उपयोग करें।