This page contains examples and source code on decision making in C programming (to choose a particular statement among many statements) and loops ( to perform repeated task ). To understand all the examples on this page, you should have knowledge of following topics:
if...else Statement
for Loop
while Loop
break and Continue Statement
switch...case
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docxrafbolet0
Spring 2014 CSCI 111 Final exam � of �1 6
1. (2 points) Flip over this test. On the back of this test write your name in the upper, left-hand
corner.
2. (2 points) What are the four parts of the compiling process (just give me 4 words, not a
paragraph).
3. (4 points) Which of the four steps of the compiling process occurs only once, regardless of
the number of source files your application has?
4. (4 points) Write a line of code that causes the preprocessor to generate an error.
5. (4 points) Write a line of code that causes the compiler to generate an error.
6. (5 points) Describe how you could incorrectly compile the joust project to cause the linker to
generate an error.
7. (5 points) Given:
1 float* fp;
2 //...
3 float pi;
4 pi=*(314 + fp);
Rewrite line 4 using array subscript notation.
Spring 2014 CSCI 111 Final exam � of �2 6
8. (5 points) Given:
1 float arr[100];
2 for(int x=0; x<100; ++x)
3 arr[x]=100-x;
What does the following expression print out?
cout << *arr << endl;
9. (14 points) Given:
int a=0;
int b=6;
int x=0;
Circle each if-expression that evaluates to true:
A) if(b)
B) if(x)
C) if(a=b==6)
D) if(a=b==5)
E) if(a=b=5)
F) if(a=x=0)
G) if(a=x==0)
Spring 2014 CSCI 111 Final exam � of �3 6
10. (10 points) Given:
1 #include<iostream>
2 using namespace std;
3
4 int main()
5 {
6 int x;
7 cout << "Enter a number greater than 10" << endl;
8 while ( x < 10 )
9 {
10 cin >> x;
11 }
12 return 0;
13 }
This program compiles just fine, and sometimes it runs as expected. But sometimes when you
run it, it exits immediately after printing "Enter a number greater than 10". That is, the program
doesn't pause for you to enter a number. Why are you getting this inconsistent behavior?
11. (4 points) What is the output of the following:
int x=4;
int y=3;
A) cout << x / y << endl;
B) cout << x % y << endl;
C) cout << x << "%" << y << endl;
D) cout << "x" << '%' << 'y' << endl;
Spring 2014 CSCI 111 Final exam � of �4 6
12. (16 points) What is the type of the expression. That is, what is the kind of thing that each
expression evaluates to. For example:
3 + 4 integer
You may assume that the variable a has been declared as an integer.
A. a + 4
B. a = 4
C. 3.14 + 4.49
D. 3 + 3.14
E. 'a'
F. cout << a
G. new float[30]
H. new float
Spring 2014 CSCI 111 Final exam � of �5 6
13. (5 points) Write a for-loop that prints out the numbers between 1 and 100 that are evenly
divisible by three.
14. (5 points) Write a while-loop that prints out the numbers between 1 and 100 that are evenly
divisible by three.
15. (5 points) Write a do-while-loop that prints out the numbers between 1 and 100 that are
evenly divisible by three.
Spring 2014 CSCI 111 Final exam � of �6 6
16. (10 points) Given:
1 #include<iostream>
2
3 class Willow {
4 publi.
Programming Fundamentals Functions in C and typesimtiazalijoono
Programming Fundamentals
Functions in C
Lecture Outline
• Functions
• Function declaration
• Function call
• Function definition
– Passing arguments to function
1) Passing constants
2) Passing variables
– Pass by value
– Returning values from functions
• Preprocessor directives
• Local and external variables
▪ Developed a recursive-descent parser to generate an intermediate representation for subsequent optimizations in Java
▪ Implemented common subexpression elimination and copy propagation on control flow graph
▪ Deployed a code generator for the source language that yields optimized native programs
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
Fundamental of C Programming Language
and
Basic Input/Output Function
contents
C Development Environment
C Program Structure
Basic Data Types
Input/Output function
Common Programming Error
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
2. Key topics and learning outcomes of this Seminar
• Reinforce the Java code introduced during Lecture 2 by
running Java code in IntelliJ;
• Develop confidence working with Intellij and logic/layout
files;
• Develop Mobile Application Programming skills;
8. Run the program, and check the terminal returns ‘Hello
World!’
B4004A L1 8
This is the ‘run’ button:
9. Type some code into Main.java and run it:
Type this code into the same file in IntelliJ and run it. Some code will need to be deleted to reflect
correctly the code below (ie the Hello World code section). Check the Terminal output.
public class Main {
public static void main(String[] args) {
int a = 2;int b = 4; int c;
c=a+b;
System.out.print(c);
}
}
Change the variables a and b to different values and then run the code again and check the
correct result shows in the Terminal.
B4004A L1 9
10. Create a for loop
Create a for loop:
public class Main {
public static void main(String[] args) {
for(int i=0;i<10;i++) {
int a = 2; int b = 4; int c;
c = a + b;
System.out.print(c);
}
}
}
… then make it print out each number on a new line by adding “n” for a new line:
System.out.print(c + "n");
… change i<10 to i<20 and run the program again to see what happens
B4004A L1 10
11. Change code to make it add 1 to each number.
… then make the program add 1 to each number and print it out in the Terminal by adding:
a = a+1;
You will need to move the declaration (int a = 2; int b = 4; int c;) out of the for loop, otherwise the result will remain static as the
program will always go back to those values. Try running it without moving the declaration first, check the output in the Terminal.
Then move it. Put it the line above the for loop. Run it again and check the output in the Terminal.
public class Main {
public static void main(String[] args) {
int a = 2; int b = 4; int c;
for(int i=0;i<13;i++) {
c = a + b;
a = a + 1;
System.out.print(c + "n");
}
}
}
B4004A L1 11
12. Using multiplication *
Change the code a little to make it run the 75 times table.
public class Main {
public static void main(String[] args) {
int a = 0; int b = 75; int c;
for(int i=0;i<13;i++) {
c = a * b;
a = a + 1;
System.out.print(c + "n");
}
}
}
B4004A L1 12
13. Concatenating Output
Change the output line of code to this and then look at the output:
System.out.print(a + " times " + b + " = " + c + "n");
Try and write some code to print a box using the character ‘X’ that prints out the same
number of ‘Xs’ across and down.
B4004A L1 13
14. Working with the if statement;
Try writing this code, changing the value of x to get it to run each statement, and then remove some lines of
code so that there are less decisions. Pay attention to the brackets. Finally end up with just an if statement,
without else.
public class Test {
public static void main(String args[]){
int x = 30;
if( x == 10 ){
System.out.print("Value of X is 10");
}else if( x == 20 ){
System.out.print("Value of X is 20");
}else if( x == 30 ){
System.out.print("Value of X is 30");
}else{
System.out.print("This is else statement");
}
}
}
B4004A L1 14
15. Summary
This seminar has reinforced the coding principles learned during the
corresponding lecture;
This seminar has provided users of IntelliJ with a good understanding
of how to manage Java code within IntelliJ Development Environment;