0% found this document useful (0 votes)
25 views

Ex 1

The document contains C++ code snippets that demonstrate basic programs to add two numbers and check if a number is positive or negative. It also includes input/output examples of running the programs.

Uploaded by

SHYAM
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Ex 1

The document contains C++ code snippets that demonstrate basic programs to add two numbers and check if a number is positive or negative. It also includes input/output examples of running the programs.

Uploaded by

SHYAM
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SSN College of Engineering, Kalavakkam – 603 110

Department of Information Technology

Subject Code: UEC2312 Staff Name: J. K. Josephine Julina


Subject Title: OOPS And Data Structures Lab Class: III SEM ECE
Batch: 2021 – 2025 Academic Year: 2022-2023

//1 a. Sum of two numbers


#include <iostream>
using namespace std;
int main()
{
int a, b;
cout<<"Enter first number: ";
cin>>a;
cout<<"Enter second number: ";
cin>>b;
cout<<"The sum is "<<a+b;
return 0;
}

Enter first number: 78


Enter second number: 56
The sum is 134

//1 b. Positive or negative


#include <iostream>
using namespace std;
int main()
{
int a;
cout<<"Enter a number: ";
cin>>a;
while(a!=0)
{
if(a<0)
cout<<a<<" is a negative number";
else
cout<<a<<" is a positive number";
a=0;
}
return 0;
}

Enter a number: -95


-95 is a negative number

Prepared by,
J. K. Josephine Julina

You might also like