11_pdfsam_lecture1 - First C program #include...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: First C program #include <stdio.h> int main(){ ssprintf(Hello World\n); ssreturn 0; } printf  prints to console Declared in stdio.h '\n' creates a newline First C program #include <stdio.h> int main(){ ssprintf(Hello World\n); ssreturn 0; } printf  prints to console Declared in stdio.h '\n' creates a newline return causes function to end (as in Java) By convention, C returns 0 if successful, and nonzero if error occured. Another C program #include <stdio.h> int main(){ ssint x = 1, y; ssint sum; ssy = 3; sssum = x + y; /* compute sum */ ssprintf(%d plus %d is %d\n, x, y, sum); ssreturn 0; } x and y are declared to be integers x initialized to be 1 y not initialized. What is the value of y? Another C program #include <stdio.h> int main(){ ssint x = 1, y; ssint sum; ssy = 3; sssum = x + y; /* compute sum */ ssprintf(%d plus %d is %d\n, x, y, sum); ssreturn 0; } x and y are declared to be integers x initialized to be 1 y not initialized. What is the value of y? Comments begin with /* and end with  */ Another C program ssy = 3; sssum = x + y; /* compute sum */ ssprintf(%d plus %d is %d\n, x, y, sum); Caution: You cannot nest comments! /* /* /* This is okay */ /* /* But this is an error */ */ Another C program ssy = 3; sssum = x + y; /* compute sum */ ssprintf(%d plus %d is %d\n, x, y, sum); Caution: You cannot nest comments! /* /* /* This is okay */ /* /* But this is an error */ */ printf can format output of variables '%d' is a placeholder for an integer value printf substitutes the placeholders for appropriate values. printf has other features Getting to know you On a piece of paper, write: Your name and Cornell NetId What you like to be called (nickname?) Your year, college, major Why are you taking 113? CS courses you have taken (+ where and when) Programming languages you have used Any concerns you have about the course ...
View Full Document

This note was uploaded on 01/10/2010 for the course CS 2022 at Cornell University (Engineering School).

Page1 / 7

11_pdfsam_lecture1 - First C program #include...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online