REEM ALAMER REVISION FOR C LANGUAGE COURSE. OUTPUTS int main (void) { int C1, C2; int *p1, *p2; C1 = 8; p1 = &C1; C2 = *p1 / 2 + 5; p2 = &C2; printf ("C1.

Slides:



Advertisements
Similar presentations
ARDUINO CLUB Session 1: C & An Introduction to Linux.
Advertisements

What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;
Lectures 10 & 11.
Senem Kumova Metin Spring2009 STACKS AND QUEUES Chapter 10 in A Book on C.
1 Week 2 Questions / Concerns Schedule this week: Homework1 & Lab1a due at midnight on Friday. Sherry will be in Klamath Falls on Friday Lexical Analyzer.
David Notkin Autumn 2009 CSE303 Lecture 13 This space for rent.
CS110 Programming Language I
Single Variable and a Lot of Variables The declaration int k; float f; reserve one single integer variable called k and one single floating point variable.
Lecture 9. Lecture 9: Outline Strings [Kochan, chap. 10] –Character Arrays/ Character Strings –Initializing Character Strings. The null string. –Escape.
Array_strcpy void array_strcpy(char dest[], char src[]) { int i = 0; while (src[i] != '\0') { dest[i] = src[i]; i++; } dest[i] = '\0'; }
Sort the given string, without using string handling functions.
C Intro.
Enter question text... 1.Enter answer text.... Enter question text... 1.Enter answer text...
 2007 Pearson Education, Inc. All rights reserved. Structs as Function Arguments and Results  Arrays – Pass by referance  Struts – the same way as the.
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
Enter question text... 1.Enter answer text.... Enter question text... 1.Enter answer text...
Hand Crafting your own program By Eric Davis for CS103.
Basic Input/Output and Variables Ethan Cerami New York
C Arrays. One-Dimensional Arrays Proper ways of declare an array in C: int hours[ 24]; double Temp [24]; int test_score [15] = { 77, 88, 99, 100, 87,
C PROGRAMMING LECTURE 17 th August IIT Kanpur C Course, Programming club, Fall by Deepak Majeti M-Tech CSE
Ping Zhang 10/08/2010.  You can get data from the user (input) and display information to the user (output).  However, you must include the library.
CECS 121 EXAM 1. /* C Programming for the Absolute Beginner */ // by Michael Vine #include main() { printf(“\nC you later\n”); system(“pause”); }
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
CPT: Strings/ Computer Programming Techniques Semester 1, 1998 Objectives of these slides: –to discuss strings and their relationship.
 2000 Prentice Hall, Inc. All rights reserved Arrays Array –Group of consecutive memory locations –Same name and type To refer to an element, specify.
C++ Character Set It is set of Characters/digits/symbol which is valid in C++. Example – A-Z, (white space) C++ Character Set It is set of.
Nested LOOPS.
CECS 121 Test 1. Functions allow you to group program statements under one name C and C++ are case-sensitive so main(), MAIN(), and Main() are all different.
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
CECS 130 EXAM 1. To declare a constant (read only) value: const int x = 20; const float PI = 3.14; Can we do this? const int x;
/* C Programming for the Absolute Beginner */ // by Michael Vine #include main() { printf(“\nC you later\n”); system(“pause”); }
1 Cannon_Chapter9 Strings and the string Class. 2 Overview  Standards for Strings  String Declarations and Assignment  I/O with string Variables 
EXERCISE Arrays, structs and file processing. Question You own a pet store. You want to keep an inventory of all the pets that you have. Pets available.
CCSA 221 Programming in C CHAPTER 11 POINTERS ALHANOUF ALAMR 1.
Computer Programming Arrays 1. Question #1 2 Question Choose the correct answer..
C Language Elements Preprocessor Directives # (sign for preprocessor directive commands) #include Standard header file (.h) Library.
C LANGUAGE UNIT 3. UNIT 3 Arrays Arrays – The concept of array – Defining arrays – Initializing arrays.
DEVRY CIS 170 C I L AB 7 OF 7 S EQUENTIAL F ILES Check this A+ tutorial guideline at sequential-files.
ARRAYS.
Lecture2.
Zhang Hongyi CSCI2100B Data Structures Tutorial 3
C Interview Questions Prepared By:.
Input/output.
Command Line Arguments
Introduction to C++ October 2, 2017.
Computer science C programming language Lesson 5
Lecture2.
Arrays in C.
Parallel Arrays Parallel array =>Two or more arrays with the same number of elements used for storing related information about a collection of data. Example:
Programming in C Input / Output.
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Programming -2 برمجة -2 المحاضرة-5 Lecture-5.
Null-Terminated Character Arrays
Introduction to Java Programming
Introduction to Programming
Programming in C Pointer Basics.
Govt. Polytechnic,Dhangar
Introduction to Programming
IPC144 Introduction to Programming Using C Week 8 – Lesson 1
Functions with arrays.
Programming in C Pointer Basics.
Strings Dr. Soha S. Zaghloul updated by Rasha ALEidan
Conversion Check your class notes and given examples at class.
EECE.2160 ECE Application Programming
Week 9 – Lesson 2 Input & Output of Character Strings
Example 1 Ask the user to type10 integers of an array T1 and 10 integers of an array T2. Put into T3, an array with 20 integers : the sum of the elements.
Arrays.
Character Arrays char string1[] = “first”;
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Structures in c By Anand George.
Presentation transcript:

REEM ALAMER REVISION FOR C LANGUAGE COURSE

OUTPUTS int main (void) { int C1, C2; int *p1, *p2; C1 = 8; p1 = &C1; C2 = *p1 / 2 + 5; p2 = &C2; printf ("C1 = %i, C2 = %i, *p1 = %i, *p2 = %i\n", C1, C2, *p1, *p2); return 0; }

OUTPUTS void test (int *int_pointer) { *int_pointer = 200; } int main (void) { int i = 10, *p = &i; printf ("Before the call to test i = %i\n", i); test (p); printf ("After the call to test i = %i\n", i); return 0; }

OUTPUTS void exchange (int * pint1, int * pint2) { int temp; temp = *pint1; *pint1 = *pint2; *pint2 = temp; } int main (void) { int i1 = 3, i2 = 12, *p1 = &i1, *p2 = &i2; printf ("i1 = %i, i2 = %i\n", i1, i2); exchange (p1, p2); printf ("i1 = %i, i2 = %i\n", i1, i2); return 0; }

OUTPUTS int main (void) { int count = 10, x; int *int_pointer; int_pointer = &count; x = *int_pointer + 4; printf ("count = %i, x = %i\n", count, x); return 0; }

ERRORS char c = 'X'; char d = 'Y'; char * const charPtr = &c; charPtr = &d;

ERRORS char Arr[81]; printf(" Please enter a text "); scanf ("%s",&Arr);

ERROR char letters[] = { "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" };

CHOOSE THE CORRECT ANSWER 1.To display a horizontal tab in the text we use: a. \t a.\v. a.\r.a.\b.

CHOOSE THE CORRECT ANSER 1.To tells scanf the maximum number of characters to read (80 characters) we write: a.scanf ("%80s", 80string); a.scanf ("%80c", string); a.scanf ("%s", 80string);a.scanf ("%c", 80string);

int values[100]; int *valuesPtr; To set the valuesPtr to point to the first element in the values array we write: a.valuesPtr = &values[1]; a.valuesPtr = values[0]; a.valuesPtr = &values[0]; a.valuesPtr = values[1];

CODE #include struct student { char name[30]; int id; double GPA; }; Write a C code to allow the user to enter information for 10 students