Write one line of code to open a file

Assignment Help C/C++ Programming
Reference no: EM132245706

Assignment -

Problem 1. To make scanf( ) return an end-of-file EOF, enter ____________________________ from the keyboard.

Problem 2. Given unsigned short int ix = -65; write out the 16 bits stored in variable ix, most significant bit first.

Problem 3. What is printed to the display?

#include <stdio.h>

main( ) {

unsigned int x=17, y=24;

printf( "%d\n", (unsigned int)(x & y) );

}

Problem 4. What is printed to the display?

#include <stdio.h>

main( ) {

unsigned int x=17, y=24;

printf( "%d\n", (unsigned int)(x && y) );

}

Problem 5. What is printed to the display?

#include <stdio.h>

main( ){

int a=1,b=2;

b=a++;

printf("%d\n",b++);

}

Problem 6. What would be the output from the code segment below?

switch ( 'b' ) {

case 'a':

printf("a\n");

case 'b':

printf("b\n");

default:

printf("default");

}

Problem 7. Which statement or statements below assign zero to the variable "result" ?

(a) result = 9%3 - 1;

(b) result = 8%3 - 1;

(c) result = 2 - 6%2;

(d) result = 2 - 8%3;

(e) none of the above

Problem 8. Given the code segment below, would the printed value be positive, negative, or zero?

char v1[ ] = "abc", v2 = "abC";

printf(%d\n",strcmp(v1,v2));

Problem 9. Write down EXACTLY what is printed to the screen by the program below.

#include <stdio.h>

main( ) {

int i=2;

printf( "i/3=%4.2f\n",(float)(i/3) );

}

Problem 10. What is printed out to the screen by the following code segment?

i=2;

printf("%d\n", (i%3) ? i: 2*i);

Problem 11. Circle ALL that are true: "Every C program must contain ..".

(a) at least one #include statement.

(b) at least one return statement.

(c) at least one preprocessor directive.

(d) at least one variable.

(e) at least one main function argument.

Problem 12. What will be printed to the screen?

#include <stdio.h>

#include <string.h>

main( ) {

char s1[ ] = "star search", s2[ ] = "axqezwars";

printf("%s\n",strncpy(s2,s1,5));

}

Problem 13. What would be printed out by the program below?

#include <stdio.h>

#define Three(x) x*3

main( ){

printf("%d\n",Three(3-1));

}

Problem 14. What would be printed out by the code segment below?

float *pf;

double * pd;

printf("%d\n",sizeof(pd)-sizeof(pf));

Problem 15. What would be printed to the screen by the program below?

#include <stdio.h>

void funct(int x, int y){

x=3;

y= 2*x;

}

main( ){

int x=2,y=2;

funct(x,y);

printf("%d\n",x+y);

}

Problem 16. Write down the output produced by the following code fragment.

for (i = 2; i < 4; ++i){

for (j = 2; j < 4; ++j){

if (i > j)printf("0");

else if (i < j)printf("1");

else if(i+j==4)printf("0");

else printf("2");

}

printf("\n");

}

Problem 17. What will be printed by the program below?

#include <stdio.h>

main( ) {

signed char i = -8, j;

j = i >> 1;

printf("%d\n",j);

}

Problem 18. Write one line of code to open a file called "myfile.txt" located in the folder "myfolder" on the "D:" partition of the drive. Open the file for reading using file pointer fp.

FILE * fp;

Problem 19. Write one printf( ) statement to print out the value of a float variable x using three digits past the decimal point left-justified in a field of width 12 characters.

Problem 20. Write two program statements: one statement to read-in a word entered by the user from the keyboard, store it in v[ ], and one statement to printout the number of characters in the word.

char v[100];

printf("Please enter a word\n");

Problem 21. Write a printf( ) statement that prints the memory address where variable dx is stored to the screen.

double dx=1.0;

Problem 22. Write a function declaration for a subroutine mysub( ) that receives a FILE pointer as input and returns a float value.

Problem 23. Write a function definition for a subroutine mysub( ) that receives two strings as input and returns an integer 1 if the second string is completely contained anywhere within the first string, and that returns an integer 0 if it is not.

Problem 24. #include<stdio.h>

main(){

int a[3]={7,8,9};

int *ptr;

// Write a single statement here so that the integer_pointer ptr points to the value 8 in the integer array a[]

}

Problem 25. Write a program to:

(a) Read in a line of text entered by the user from the keyboard. The user may type in tabs, blanks spaces, and any characters whatsoever followed by the Enter key.

(b) If the line of text does not contain at least two commas, print the phrase "Data Entry Error" to the display.

(c) Note that the two commas might occur one-right-after-the-other. If the first two commas in the line of text occur one-right-after-the-other, print the phrase "Missing Field" to the display.

(d) If the first two commas in the line of text are separated by some text, print that text to the display. Note, the text between the first two commas may include tabs or blank spaces.

Attachment:- Assignment Files.rar

Reference no: EM132245706

Questions Cloud

What are the possible differential diagnoses at given time : It is anticipated that the initial discussion response should be in the range of 250-300 words. Response posts must demonstrate topic knowledge and scholarly.
Review the essential elements of a fetal assessment : Review the essential elements of a fetal assessment during the last trimester of pregnancy. What are the clinical indicators of fetal well being.
In what areas can the practitioner improve : In what areas can the practitioner improve? At this point in the clinical interview, do you have any compelling concerns? If so, what are they?
New product development project : For this assignment you are to develop a new product concept and research the demand, proposed product attributes,
Write one line of code to open a file : Write one line of code to open a file called "myfile.txt" located in the folder "myfolder" on the "D:" partition of the drive
Evaluate management tools used in the organization : Evaluate management tools used in the organization, indicating potential strengths and weaknesses.
Describe one adult learning theory that is not covered : Write a four-five page paper that describes one adult learning theory that is not covered in the textbook how that theory incorporates.
Write the executive summary section of your strategic audit : Write the Executive Summary section or the beginning of your Strategic Audit Report.
Examine the decision-making process in business : Examine the decision-making process in business and its importance. Provide an example of a business decision based on multiple choices made.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd