Kishan - Prog Lab

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Kishan Kumar 22564

Civil Engineering

Question 4
Program code
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
int sum=0;

for (int num=1567; num<9876; num++)


{
if (num % 7 ==0)
{ cout<<num<<" ";
sum +=num;
}
}

cout<<endl;
cout<<sum;

return 0;

Sample Output
Kishan Kumar 22564
Civil Engineering

Question 5
Program Code

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {

int num;

cout<<"Please enter a number : ";


cin>>num;

if (num > 0 )
{
if (num == 2 || num == 3 || num == 5 || num == 7)
cout<<"The number you entered IS a prime number";

else if ( num%2==0 || num%3==0 || num%5==0 || num%7==0)


{ cout<<"The number you entered IS NOT a prime number "; }

else
cout<<"The number you entered IS a prime number";
}

else
cout<<"Please enter a positive number";

return 0;
}

Sample Output

You might also like