Preview

Nt1310 Unit 1 Assignment 2

Satisfactory Essays
Open Document
Open Document
426 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Nt1310 Unit 1 Assignment 2
Data Structure
Syed Sheraz Ali Shah
01-161142-106
Assignment 3

Q1) Write a program of if else?
Ans:
#include
#include
using namespace std;

int main()
{
int num; cout << "Please enter integer:- "; cin >> num;

if ( num > 0) { cout << "You have entered a +ve integer:- " << num << endl; } else if (num<< "You have entered a -ve integer:- " << num << endl; } else { cout<<
#include
using namespace std;

int main()
{
int num, i = 1, factorial = 1;

cout << "You are in factorial program of C++. Please enter a +ve integer:- "; cin >> num; while ( i <<< num <<< factorial; getch(); return 0;
}

Q3) Write a program of do-while program C++?
Ans:
#include
#include
using namespace std;

int main()
{
float num, sum = 0.0; do { cout<>num; sum += num; } while(num != 0.0);

cout<<
#include
using namespace std;

int main()
{
char o; float num1, num2;

cout << "Select the operator you want to work (+ for addition, - for subtraction , * for multiplication , / for division):- "; cin >> o;

cout << "Enter any two numbers:- "; cin >> num1 >> num2; switch (o) { case '+': cout << num1 << " + " << num2 << " = " << num1+num2; break; case '-': cout << num1 << " - " << num2 << " = " << num1-num2; break; case '*': cout << num1 << " * " << num2 << " = " << num1*num2; break; case '/': cout << num1 << " / " << num2 << " = " << num1/num2; break; default: cout << "Invalid selection! Please correct operator thankyou"; break; } getch(); return 0;
}

Q5) Write a program of For in C++?
Ans:
#include
#include
using namespace std;

int main()
{
int n, factorial = 1;

cout << "Please enter +ve integer: "; cin >> n;

for (int i = 1; i << "Factorial of

You May Also Find These Documents Helpful

  • Satisfactory Essays

    This paper will discuss the three types of network topologies discussed in Chapter 3. They are, hierarchical star, bus, and ring network topologies. Each has its advantages and disadvantages as will be discussed…

    • 398 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    The stylist researched two perspective vendors to determine the best option for the salon. The two vendors researched were Alternative 1, Alicia Lee representing Dudley hair care products and Alternative 2, Frank Milam representing Design Essential hair care products. The criteria used to judge the two alternatives were as follows: price, service, quality and delivery. The research included online research (comparing prices) calling other salons, and testing the products. The evaluation of the two alternatives points out that Alternative 2, Frank Milam with Design Essentials should be recommended. The recommendation shows they offer better pricing, savings of $5.75 - $12.75 for a bottle of shampoo, better promotions for purchasing products, they have a quality money back guarantee and faster delivery…

    • 809 Words
    • 4 Pages
    Powerful Essays
  • Powerful Essays

    Nt1310 Unit 1 Assignment 2

    • 2615 Words
    • 11 Pages

    There are several important elements of research such as, the concept and construct, variables, qualitative and quantitative research, nature of measurements, level of measurements, measurement scale, rating scale and also the reliability and validity.…

    • 2615 Words
    • 11 Pages
    Powerful Essays
  • Better Essays

    printf(" %d \t\t %d\n\n",stfor->wt,stfor->tt); ttl_wt += stfor->wt; ttl_tt += stfor->tt; temp = np = stfor; del_node(np,1) ; ++i; } else { stfor->bt -= qt; stfor->tt = temp->tt + qt; printf(" %d \t\t %d\n\n",stfor->wt,stfor->tt); np = temp = stfor; del_node(np,2); ins_node(temp); } }while(stfor !=…

    • 401 Words
    • 2 Pages
    Better Essays
  • Satisfactory Essays

    G. Work in pairs. Now go back to exercise D. Use five words in the vocabulary box to help you make another five sentences about a list of things to do or take for a picnic. Remember to use imperatives.…

    • 60 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    Understand the task. If your teacher, teacher, or president gives you your guidance about your report, be sure to read it (and re-read it). What task does it ask you to do? Are you supposed to tell your audience about a topic? In general, if you are writing a report for a primary, intermediate or secondary class, you will be asked to submit a topic without including your opinion. Other tasks may ask you to convince your audience in a certain way to understand your subject or analyze a topic. Ask your teacher for any questions you may have as soon as possible. [1]…

    • 131 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Cis 324 Midterm and Answers

    • 2743 Words
    • 11 Pages

    | A name for the function, a name for each parameter, and a name for the return value…

    • 2743 Words
    • 11 Pages
    Good Essays
  • Satisfactory Essays

    Hospital and Square Feet

    • 389 Words
    • 2 Pages

    “Indeed, Allah will not change the condition of a people until they change what is in themselves.” (Al-Quran 13:11)…

    • 389 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    C++ Midterm

    • 2831 Words
    • 12 Pages

    What is the value inside the "value" variable at the end of the given code snippet?…

    • 2831 Words
    • 12 Pages
    Good Essays
  • Good Essays

    Viscosity

    • 2279 Words
    • 10 Pages

    fd gcms cm   gcm 1 s 1  1 piose  1P Av cm 2 cms  2…

    • 2279 Words
    • 10 Pages
    Good Essays
  • Good Essays

    Macro Econ

    • 924 Words
    • 4 Pages

    c + i + g + x-m = y = c + s + t…

    • 924 Words
    • 4 Pages
    Good Essays
  • Good Essays

    C QUESTIONS & ANSWERS

    • 604 Words
    • 6 Pages

    With what do you replace the ???? to make the function shown above return the correct answer?…

    • 604 Words
    • 6 Pages
    Good Essays
  • Powerful Essays

    //for (int i=0; i < x; i++) //while (x == y) if (x == y) { something(); somethingelse(); }…

    • 1229 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    Introduction to Computing

    • 467 Words
    • 2 Pages

    Write a program that reads three nonzero integers and determines and prints if they could be the sides of a right triangle.…

    • 467 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    int function1(char x) { //parameter x passed to the function, function returns an integer value…

    • 1596 Words
    • 7 Pages
    Good Essays