Computers Engineering Data - Freshers Dunia.in
Kanalga Telegram’da o‘tish
🎯 Welcome to our Telegram channel . will get most recent Engineering and Diploma updates along with daily MCQs, notes,Books for CS/IT, Diploma solve manual. and Placements Related material are Available. all detail available and stay update.
Ko'proq ko'rsatish1 281
Obunachilar
-224 soatlar
-47 kun
-1130 kun
Postlar arxiv
1. Program to print "Hello World!!".
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hello World!!");
getch();
}
2. Program to Add Two Numbers.
#include<iostream>
using namespace std;
int main()
{
//variable declaration
int num1, num2, result;
//take user input
cout << "Enter first Number : ";
cin >> num1;
cout << "\nEnter second Number : ";
cin >> num2;
//to add two number
result = num1 + num2;
//display addition
cout << "\nAddition is : " << result;
return 0;
}
3. Program to Check if the Number is Positive or Negative.
#include<iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter any non-zero Number:";
cin >> num;
if (num > 0)
{
cout << "Number is positive";
}
else
{
cout << "Number is negative";
}
return 0;
}
4. Program to Check whether the number is Even or Odd.
#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter an integer : ";
cin>>n;
if(n % 2 == 0)
{
cout<<n<<" is even.";
}
else
{
cout << n << " is odd.";
}
return 0;
}
5. Program to Accept Two Values of a & b and Swap their Values.
#include<iostream>
using namespace std;
int main()
{
int var1, var2, swap;
cout<<"Enter value for first integer: ";
cin>>var1;
cout<<"Enter value for second integer: ";
cin>>var2;
cout<<"\nValues Before swapping: \n"<<endl;
cout<<"First Integer ="<<var1<<endl;
cout<<"Second Interger ="<<var2<<endl;
swap=var1;
var1=var2;
var2=swap;
cout<<"\nValues After swapping: \n"<<endl;
cout<<"First Integer ="<<var1<<endl;
cout<<"Second Interger ="<<var2<<endl;
return 0;
}
6. Program to Accept value of base & height and Calculate Area of Triangle.
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
float base,height;
float area;
cout<<"Enter base of Triangle : ";
cin>>base;
cout <<"Enter height of Triangle : ";
cin>>height;
area = 0.5 * (base * height);
cout<<"Area of Triangle :"<<area;
return 0;
}
1. Program to Print Hello World.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"Hello World";
getch();
}
