ACTIVITY IN C++
COMPUTER FUNDAMENTALS AND PROGRAMMING
Name: Danilo B. Simara III
Course. Year, & Section: BSCE 1A
Instructor: Ms. Joanna H. Estallo
1. Write a program in C++ to print a welcome text in a separate line.
/* The code below will print a welcome text in a separate line */
#include <iostream>
using namespace std;
int main()
{
cout << " \n"; /*this line is blank, to provide the separate line for the welcoming message*/
cout << "Welcome to Computer Fundamentals and Programming \n" ; //this is the welcoming message
}
2. Write a program in C++ to print the sum of two numbers.
/* The code below will print the sum of two numbers */
#include <iostream>
using namespace std;
int main()
{
int num1; //num1 is the first number
int num2; //num2 is the second number
int sum;
num1=58;
num2=83;
sum=num1+num2;
cout << " The sum of "<< num1 << " and "<< num2 <<" is : "<< sum <<"\n\n" ;
}
1
3. Write a program in C++ to find Size of fundamental data types.
/* The code below will find Size of fundamental data types */
#include <iostream>
using namespace std;
int main()
{
cout << " The sizeof(float) is : " << sizeof(float) << " bytes \n" ;
cout << " The sizeof(int) is : " << sizeof(int) << " bytes \n" ;
cout << " The sizeof(double) is : " << sizeof(double) << " bytes \n";
cout << " The sizeof(char) is : " << sizeof(char) << " bytes \n" ;
cout << " The sizeof(bool) is : " << sizeof(bool) << " bytes \n\n";
}
4. Write a program in C++ to print the sum of two numbers using variables.
/* The code below will print the sum of two numbers using variables. */
#include <iostream>
using namespace std;
int main()
{
int num1 = 5; //num1 is the first number
int num2 = 8; //num2 is the second number
int sum = num1 + num2;
cout << sum;
}