// Taking inputs ( integers in cpp )
#include <iostream>
#include <string>
int main() {
std::string num1, num2;
std::cout << "Enter first number: ";
std::cin >> num1;
std::cout << "Enter second number: ";
std::cin >> num2;
// Typecasting string to integer
int num1Int = std::stoi(num1);
int num2Int = std::stoi(num2);
std::cout << "Sum of numbers is " << num1Int + num2Int << std::endl;
return 0;
}
// @CPP_Coding
#include <iostream>
#include <string>
int main() {
std::string num1, num2;
std::cout << "Enter first number: ";
std::cin >> num1;
std::cout << "Enter second number: ";
std::cin >> num2;
// Typecasting string to integer
int num1Int = std::stoi(num1);
int num2Int = std::stoi(num2);
std::cout << "Sum of numbers is " << num1Int + num2Int << std::endl;
return 0;
}
// @CPP_Coding
//To check numbers Amicable or not..
//Definition of Amicable nums:👉Amicable numbers are two different positive integers such that each number is the sum of the proper divisors of the other number...😊
#include<iostream>
using namespace std;
int s_divisors (int N) {
int i,s=0;
for(i=1; i<=N/2; i++) {
if(N%i==0)
s=s+i;
}
return s;
}
int main() {
int a,b;
cout<<"Enter first number:";
cin>>a;
cout<<"Enter second number:";
cin>>b;
if((s_divisors(a)==b)&&(s_divisors(b)==a))
cout<<a<<" and "<<b<<" are Amicable✔️";
else
cout<<a<<" and "<<b<<" are Not Amicable❌";
return 0;
}
//@CPP_Coding
//Definition of Amicable nums:👉Amicable numbers are two different positive integers such that each number is the sum of the proper divisors of the other number...😊
#include<iostream>
using namespace std;
int s_divisors (int N) {
int i,s=0;
for(i=1; i<=N/2; i++) {
if(N%i==0)
s=s+i;
}
return s;
}
int main() {
int a,b;
cout<<"Enter first number:";
cin>>a;
cout<<"Enter second number:";
cin>>b;
if((s_divisors(a)==b)&&(s_divisors(b)==a))
cout<<a<<" and "<<b<<" are Amicable✔️";
else
cout<<a<<" and "<<b<<" are Not Amicable❌";
return 0;
}
//@CPP_Coding
👍3
//To find Largest word and Smallest word in a string..
#include<iostream>
#include<string.h>
using namespace std;
int main() {
char str[100]= {0},substr[100][100]= {0};
cout<<"Enter string:";
cin.getline (str, 100);
int i = 0, j = 0, k = 0, a, minIndex = 0, maxIndex = 0, max = 0, min = 0;
while (str[k] != '\0') {
j = 0;
while (str[k] != ' ' && str[k] != '\0' && str[k]!='.') {
substr[i][j] = str[k];
k++;
j++;
}
substr[i][j] = '\0';
i++;
if (str[k] != '\0') {
k++;
}
}
int len = i;
max = strlen(substr[0]);
min = strlen(substr[0]);
for (i = 0; i < len; i++) {
a = strlen(substr[i]);
if (a > max) {
max = a;
maxIndex = i;
}
if (a < min) {
min = a;
minIndex = i;
}
}
cout<<"Largest Word is:" <<substr[maxIndex]<<endl<<"Smallest word is:"<<substr[minIndex]<<endl;
return 0;
}
//@CPP_Coding
#include<iostream>
#include<string.h>
using namespace std;
int main() {
char str[100]= {0},substr[100][100]= {0};
cout<<"Enter string:";
cin.getline (str, 100);
int i = 0, j = 0, k = 0, a, minIndex = 0, maxIndex = 0, max = 0, min = 0;
while (str[k] != '\0') {
j = 0;
while (str[k] != ' ' && str[k] != '\0' && str[k]!='.') {
substr[i][j] = str[k];
k++;
j++;
}
substr[i][j] = '\0';
i++;
if (str[k] != '\0') {
k++;
}
}
int len = i;
max = strlen(substr[0]);
min = strlen(substr[0]);
for (i = 0; i < len; i++) {
a = strlen(substr[i]);
if (a > max) {
max = a;
maxIndex = i;
}
if (a < min) {
min = a;
minIndex = i;
}
}
cout<<"Largest Word is:" <<substr[maxIndex]<<endl<<"Smallest word is:"<<substr[minIndex]<<endl;
return 0;
}
//@CPP_Coding
👍1
//Convert string to Title Case🌚
#include<iostream>
using namespace std;
void titleCase(char str[]) {
int x=0;
int prevChar=' ';
while(str[x]!='\0') {
if (prevChar==' ' or prevChar=='\t' or prevChar=='\n') {
if(str[x]>='a'&& str[x]<='z')
str[x]=str[x]-32;
}
else if(str[x]>='A'&& str[x]<='Z')
str[x]=str[x]+32;
prevChar=str[x];
x++;
}
}
int main() {
char str[50];
cout<<"Enter a string:";
cin.getline(str,50);
titleCase(str);
cout<<str;
return 0;
}
//@CPP_CODES_PRO
👍2
Notes 📝 :
Telegram.me/BCA_Sem1_Notes
Telegram.me/BCA_Sem2_Notes
Telegram.me/BCA_Sem3_Notes
Telegram.me/BCA_Sem4_Notes
Telegram.me/BCA_Sem5_Notes
Telegram.me/BCA_Sem6_Notes
Code practice Channels:
Telegram.me/C_Codes_pro
Telegram.me/CPP_Codes_pro
Telegram.me/Python_Codes_pro
Telegram.me/Java_Codes_Pro
Telegram.me/Nodejs_Codes_Pro
Info channel:
Telegram.me/Btech_bca_mca
Discussion groups:
Telegram.me/bca_mca_btech
Telegram.me/bca_group_ignou
Learn coding:
Youtube.com/IgnouStudyCenter
Telegram.me/BCA_Sem1_Notes
Telegram.me/BCA_Sem2_Notes
Telegram.me/BCA_Sem3_Notes
Telegram.me/BCA_Sem4_Notes
Telegram.me/BCA_Sem5_Notes
Telegram.me/BCA_Sem6_Notes
Code practice Channels:
Telegram.me/C_Codes_pro
Telegram.me/CPP_Codes_pro
Telegram.me/Python_Codes_pro
Telegram.me/Java_Codes_Pro
Telegram.me/Nodejs_Codes_Pro
Info channel:
Telegram.me/Btech_bca_mca
Discussion groups:
Telegram.me/bca_mca_btech
Telegram.me/bca_group_ignou
Learn coding:
Youtube.com/IgnouStudyCenter
C++ Codes basic to advance pinned «Notes 📝 : Telegram.me/BCA_Sem1_Notes Telegram.me/BCA_Sem2_Notes Telegram.me/BCA_Sem3_Notes Telegram.me/BCA_Sem4_Notes Telegram.me/BCA_Sem5_Notes Telegram.me/BCA_Sem6_Notes Code practice Channels: Telegram.me/C_Codes_pro Telegram.me/CPP_Codes_pro Telegram…»
//To check leap year//@CPP_CODES_PRO
#include<iostream>
using namespace std;
int main() {
int year;
cout << "Enter a year that you want to check:";
cin>>year;
if((year%4==0 &&year%100!=0) ||( year%400==0))
cout<<year<<" is a leap year"<<endl;
else
cout<<year<<" is not a leap year"<<endl;
return 0;
}
इस बाॅट में कोड रन करना सीखें।
Learn how to run code in this bot.
See bot with Full tutorial: https://t.me/logicBots/147
लाभ (Advantage):
आप किसी को भी रियल टाइम में कोड का आउटपुट दिखा सकते हो, जिससे अगर आपके कोड में कोई गलती है तो वह भी सरलता से एक दूसरे से डिस्कस करके साॅल्व कर सकते हो।
See features written in pic ☝️☝️
You can show the output of the code to anyone in real time, so that if there is any mistake in your code, they can easily solve it by discussing with each other.
Full tutorial: https://t.me/logicBots/147
👍1
// Print any number table
#include <iostream>// @CPP_Codes_pro
using namespace std;
int main() {
int num;
cout << "Enter a number: ";
cin >> num;
cout << "Table of " << num << ":" << endl;
for(int i=1; i<=10; i++) {
cout << num << " x " << i << " = " << num*i << endl;
}
return 0;
}
👍1
// Swastik pattern
#include<iostream>
using namespace std;
int main() {
int n;
cout << "Enter Number: ";
cin >> n;
for(int k = 1; k <= n * 2 - 1; k++) {
for(int l = 1; l <= n * 2 - 1; l++) {
if(k == n || l == n || k == 1 && l >= n || k <= n && l == 1 || k >= n && l == n * 2 - 1 || k == n * 2 - 1 && l <= n)
cout << " *";
else
cout << " ";
}
cout << endl;
}
return 0;
}
/*1 2 3 4
1 2 3
1 2
1*/
1 2 3
1 2
1*/
#include<iostream>
using namespace std;
int main() {
int n;
cout<<"Enter range:";
cin>>n;
for(int i=n; i>=1; i--) {
for(int j=1; j<=i; j++) {
cout<<j<<" ";
}
cout <<endl;
}
return 0;
}
/*4
3 4
2 3 4
1 2 3 4*/
3 4
2 3 4
1 2 3 4*/
#include<iostream>
using namespace std;
int main() {
int n;
cout<<"Enter range:";
cin>>n;
for(int i=n; i>=1; i--) {
for(int j=i; j<=n; j++) {
cout<<j<<" ";
}
cout <<endl;
}
return 0;
}
👍1
Ab aap log apna khud ka Compiler bot bana sakte hain easily 🥳🥳🔥
Apne manpasand name aur username se
Create your own
By using @CloneCompiler_bot
See full details: Click Here
Apne manpasand name aur username se
Create your own
By using @CloneCompiler_bot
See full details: Click Here
// Event Emitter class
#include <iostream>
#include <functional>
#include <vector>
using namespace std;
class EventEmitter {
private:
struct FuncObj {
string mesType;
std::function<void(int)> callback;
};
vector<FuncObj> funcs;
public:
EventEmitter() {}
void on(string mesType, std::function<void(int)> callback) {
funcs.push_back(FuncObj{ mesType, callback });
}
void emit(string mesType, int obj) {
for (auto& funobj : funcs) {
if (funobj.mesType == mesType) {
funobj.callback(obj);
}
}
}
};
void callback(int a) {
cout << "hi" << a;
}
int main() {
EventEmitter e;
e.on("message", callback);
e.emit("message", 7);
return 0;
}
❤1
Make your 30 numbers final in c/c++ 👇
https://t.me/C_Codes_pro/254
All that program can be converted in c++ just replacing
stdio.h to iostream
And
printf to std::cout
https://t.me/C_Codes_pro/254
All that program can be converted in c++ just replacing
stdio.h to iostream
And
printf to std::cout
👍1
Now it's discussion group is public
Join @Cpp_group_pro
Join @Cpp_group_pro
Select your group/channel/service
t.me/Sid_info/69
t.me/Sid_info/69
// Check leap year
#include <iostream>
bool isLeapYear(int year) {
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
return true;
} else {
return false;
}
}
int main() {
int year;
std::cout << "Enter a year: ";
std::cin >> year;
if (isLeapYear(year)) {
std::cout << year << " is a leap year." << std::endl;
} else {
std::cout << year << " is not a leap year." << std::endl;
}
return 0;
}
👍3