Output of above code?
Anonymous Quiz
27%
A) 10
13%
B) Undefined Behavior
52%
C) 20
8%
D) Compilation Error
π2
Program to swap values of two variables.
#include <iostream>
int main() {
int a=1;
int b=2;
int temp;
std::cout << "Before Swapping:\n";
std::cout << "a=" << a <<",b=" << b <<"\n";
temp = a;
a=b;
b=temp;
std::cout << "After Swapping:\n";
std::cout << "a=" << a <<",b=" << b <<"\n";
return 0;
}
π5β€1
C & C++ PROGRAMMING
https://youtu.be/TBQrLkcK1KQ?si=9fGmOTMDKDx8w8Ht
π100% Ai ka use krk Music Rap Video bnaya π
Plz watch guys and give some response about video π
Plz watch guys and give some response about video π
Program to swap values of two variables.
#include <iostream>
int main() {
int a=1;
int b=2;
int temp;
std::cout << "Before Swapping:\n";
std::cout << "a=" << a <<",b=" << b <<"\n";
temp = a;
a=b;
b=temp;
std::cout << "After Swapping:\n";
std::cout << "a=" << a <<",b=" << b <<"\n";
return 0;
}
Program to convert temperature from Fahrenheit to Celsius.
#include <iostream>
using namespace std;
int main() {
double fahrenheitTemperature;
double temperatureInCelsius;
cout << "Enter your temperature in Fahrenheit:";
cin >> fahrenheitTemperature;
temperatureInCelsius = ((fahrenheitTemperature - 32) * 5) / 9;
cout << "Temperature in celsius : " << temperatureInCelsius;
return 0;
}
Program : To calculate factorial of a given number
cpp
#include <iostream>
using namespace std;
int main() {
int num,res=1;
cout << "Enter a positive number:" << endl;
cin >> num;
if(num < 0){
cout << "You entered a negative number" << endl;
}
else if(num == 0){
cout << "0! = " << "1";
}
else{
for(int i = 1;i <= num;i++){
res = res * i;
}
cout << "Factorial of " << num << " is "<<res;
}
return 0;
}
Program: Given an array with numbers 11,12,13,14,15 calculate the sum of elements in array using range based for loop.
cpp
#include <iostream>
using namespace std;
int main(){
int numbers[] = {11,12,13,14,15};
int sum = 0;
for(int number : numbers){
sum = sum + number;
}
cout << "Sum = "<< sum;
return 0;
}
Program : Design a number guessing game using while loop.
Take range of numbers from 1 - 10
hard code any number between 1 and 10
Ask user to guess the number after guessing display number of attempts made to guess the number.
Take range of numbers from 1 - 10
hard code any number between 1 and 10
Ask user to guess the number after guessing display number of attempts made to guess the number.
cpp
#include <iostream>
using namespace std;
int main()
{
int numberToGuess = 4;
int attempts = 0;
int guess = 0;
while (guess != numberToGuess)
{
cout << "Guess the number between 1 and 10:" << endl;
cin >> guess;
attempts++;
if(guess == numberToGuess){
cout << "You guessed it right in " << attempts << " attempts" << endl;
}
}
cout << "Game ended";
return 0;
}
Program : Design a number guessing game using while loop.
Take range of numbers from 1 - 10
hard code any number between 1 and 10
Ask user to guess the number after guessing display number of attempts made to guess the number.
Take range of numbers from 1 - 10
hard code any number between 1 and 10
Ask user to guess the number after guessing display number of attempts made to guess the number.
cpp
#include <iostream>
using namespace std;
int main()
{
int numberToGuess = 4;
int attempts = 0;
int guess = 0;
while (guess != numberToGuess)
{
cout << "Guess the number between 1 and 10:" << endl;
cin >> guess;
attempts++;
if(guess == numberToGuess){
cout << "You guessed it right in " << attempts << " attempts" << endl;
}
}
cout << "Game ended";
return 0;
}
β€4π1
π Unlock Your Career in C++ & DSA! π
Are you ready to dive into the world of programming? π»β¨ We have the *ultimate* collection of C++ and DSA courses that can set you on the path to success! π
π΅ C++ & C++ with DSA Masterclass
π‘ ALPHA DSA C++ - Stand Out in the Crowd!
π PW C++ DSA - Propel Your Skills!
π₯ Love Babbar Supreme Batch - Learn from the Best!
π DSA by Abdul Bari - Expert Guidance!
β NARESH IT DSA - Proven Techniques!
π± Durgasoft DSA - Grab Your Opportunity!
π€‘ Ashok IT - Fun and Engaging Learning!
β¨ Exclusive Offer: Get Access for Only βΉ100! β¨
Originally valued at βΉ10,000, this is your chance to grab it at an unbelievable 1% of the price! π°
Donβt miss out on this incredible opportunity to enhance your skills and boost your career! π
π¬ Message us now at:
@Myhurthearts
@imabhi3030
π Invest in your future today! π
Are you ready to dive into the world of programming? π»β¨ We have the *ultimate* collection of C++ and DSA courses that can set you on the path to success! π
π΅ C++ & C++ with DSA Masterclass
π‘ ALPHA DSA C++ - Stand Out in the Crowd!
π PW C++ DSA - Propel Your Skills!
π₯ Love Babbar Supreme Batch - Learn from the Best!
π DSA by Abdul Bari - Expert Guidance!
β NARESH IT DSA - Proven Techniques!
π± Durgasoft DSA - Grab Your Opportunity!
π€‘ Ashok IT - Fun and Engaging Learning!
β¨ Exclusive Offer: Get Access for Only βΉ100! β¨
Originally valued at βΉ10,000, this is your chance to grab it at an unbelievable 1% of the price! π°
Donβt miss out on this incredible opportunity to enhance your skills and boost your career! π
π¬ Message us now at:
@Myhurthearts
@imabhi3030
π Invest in your future today! π
π2
Program : Sum on n natural numbers using do while loop.
#include <iostream>
using namespace std;
int main() {
int n,sum=0,i=1;
cout << "Enter the value of n:";
cin >> n;
do{
sum = sum + i;
i++;
}while(i <= n);
cout << "Sum of "<< n << " natural numbers :" << sum;
}
π3
Program : Write a function to find maximum of two numbers.
#include <iostream>
using namespace std;
int findMax(int n1 , int n2){
if(n1 > n2){
return n1;
}
return n2;
}
int main() {
int num1,num2;
cout << "Enter any two different numbers:"<<endl;
cin >> num1 >> num2;
int max = findMax(num1,num2);
cout << "Maximum of "<< num1 << " and " << num2 << " is " << max;
return 0;
}
π3
Program : Write a function to find maximum of two numbers.
#include <iostream>
using namespace std;
int findMax(int n1 , int n2){
if(n1 > n2){
return n1;
}
return n2;
}
int main() {
int num1,num2;
cout << "Enter any two different numbers:"<<endl;
cin >> num1 >> num2;
int max = findMax(num1,num2);
cout << "Maximum of "<< num1 << " and " << num2 << " is " << max;
return 0;
}
π3
π Unlock Your Career in C++ & DSA! π
Are you ready to dive into the world of programming? π»β¨ We have the *ultimate* collection of C++ and DSA courses that can set you on the path to success! π
π΅ C++ & C++ with DSA Masterclass
π‘ ALPHA DSA C++ - Stand Out in the Crowd!
π PW C++ DSA - Propel Your Skills!
π₯ Love Babbar Supreme Batch - Learn from the Best!
π DSA by Abdul Bari - Expert Guidance!
β NARESH IT DSA - Proven Techniques!
π± Durgasoft DSA - Grab Your Opportunity!
π€‘ Ashok IT - Fun and Engaging Learning!
Donβt miss out on this incredible opportunity to enhance your skills and boost your career! π
π¬ Message us now at:
@Myhurthearts
@imabhi3030
π Invest in your future today! π
Are you ready to dive into the world of programming? π»β¨ We have the *ultimate* collection of C++ and DSA courses that can set you on the path to success! π
π΅ C++ & C++ with DSA Masterclass
π‘ ALPHA DSA C++ - Stand Out in the Crowd!
π PW C++ DSA - Propel Your Skills!
π₯ Love Babbar Supreme Batch - Learn from the Best!
π DSA by Abdul Bari - Expert Guidance!
β NARESH IT DSA - Proven Techniques!
π± Durgasoft DSA - Grab Your Opportunity!
π€‘ Ashok IT - Fun and Engaging Learning!
Donβt miss out on this incredible opportunity to enhance your skills and boost your career! π
π¬ Message us now at:
@Myhurthearts
@imabhi3030
π Invest in your future today! π
Which of the following is the correct way to write a comment in C?
Anonymous Quiz
55%
// This is a comment
35%
/* This is a comment */
7%
# This is a comment
3%
-- This is a comment
What is the correct format specifier for printing a float in C?
Anonymous Quiz
9%
%d
80%
%f
9%
%c
4%
%s
Which operator is used to access the value at the address stored in a pointer?
Anonymous Quiz
38%
&
43%
*
11%
@
9%
#
Which keyword is used to define a constant in C?
Anonymous Quiz
23%
constant
8%
define
63%
const
6%
static
What are assignment operator ?
Anonymous Quiz
48%
=
12%
& , || , !=
30%
< , > <= , >=
10%
+ , - , * / , %
π1
π Unlock Your Career in C++ & DSA! π
π΅
π Invest in your future today! π
Join for Free Course β https://t.me/addlist/vnAFuK9rY6FjNjM1
Are you ready to dive into the world of programming? π»β¨ We have the *ultimate* collection of C++ and DSA courses that can set you on the path to success! π
π΅
C++ & C++ with DSA Masterclass
π‘ ALPHA DSA C++ - Stand Out in the Crowd!
π PW C++ DSA - Propel Your Skills!
π₯ Love Babbar Supreme Batch - Learn from the Best!
π DSA by Abdul Bari - Expert Guidance!
β NARESH IT DSA - Proven Techniques!
π± Durgasoft DSA - Grab Your Opportunity!
π€‘ Ashok IT - Fun and Engaging Learning!
Ineuron All DSA course & 10+ more DSA courses
Donβt miss out on this incredible opportunity to enhance your skills and boost your career! π
π¬ Message us now at:
@Myhurthearts
@imabhi3030
π Invest in your future today! π
Join for Free Course β https://t.me/addlist/vnAFuK9rY6FjNjM1
π1