Preview

Nt1310 Unit 4

Better Essays
Open Document
Open Document
3614 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Nt1310 Unit 4
1. Point out the error in the following program

main()
{
const char *fun();
*fun()='A';
} const char *fun()
{
return "Hello";
}
Ans. fun() returns to a "const char" pointer which cannot be modified

2. What would be the output of the following program?

main()
{
const int x=5; int *ptrx; ptrx=&x; *ptrx=10; printf("%d",x); }
a) 5 b) 10 c) Error d) Garbage value

3. A switch statement cannot include

a) constants as arguments b) constant expression as arguments
c) string as an argument d) None of the above

4. How long the following program will run?

main()
{
printf("\nSonata Software"); main(); }
a) infinite loop b) until the stack overflows
c) All of the above d) None of the above

5. On combining
…show more content…

The program is trying to collect the value of a "void" function into an integer variable.

7. In the following program how would you print 50 using p?

main()
{
int a[]={10, 20, 30, 40, 50}; char *p; p= (char*) a;
}
Ans. printf("\n%d",*((int*)p+4));

8. Would the following program compile?

main()
{
int
…show more content…

If the following program (myprog) is run from the command line as myprog 1 2 3, What would be the output?

main(int argc, char *argv[])
{
int i,j=0; for(i=0;i<argc;i++) j=j+ atoi(argv[i]); printf("%d",j); }
a) 1 2 3 b) 6 c) error d) "123"

13. If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday? What would be the output?

main(int argc, char *argv[])
{
while(--argc >0) printf("%s",*++argv); }
a) myprog monday tuesday wednesday thursday b) monday tuesday wednesday thursday
c) myprog tuesday thursday d) None of the above

14. In the following code, is p2 an integer or an integer pointer?

typedef int* ptr ptr p1,p2;
Ans. Integer pointer

15. If the following program (myprog) is run from the command line as myprog friday tuesday sunday, What would be the output?

main(int argc, char *argv[])
{
while(sizeofargv) printf("%s",argv[--sizeofargv]); }
a) myprog friday tuesday sunday b) myprog friday tuesday
c) sunday tuesday friday myprog d) sunday tuesday friday

16. What would be the output of the following program?

main()
{
int i=4;


You May Also Find These Documents Helpful

  • Good Essays

    Nt1310 Unit 4

    • 313 Words
    • 2 Pages

    1) Block B in Fig. 6-31 weighs 603 N. The coefficient of static friction between block and table is 0.32; angle θ is 33°; assume that the cord between B and the knot is horizontal. Find the maximum weight of block A for which the system will be stationary.…

    • 313 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    Mat 540 Week 4 Paper

    • 1775 Words
    • 8 Pages

    * Provide a set of values that will test the normal operation of this program segment. Defend your choices.…

    • 1775 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    NT1430 UNIT 2

    • 565 Words
    • 3 Pages

    10) Experiment by calling the ‘file’ utility with names of files in /usr/bin. How many different types of files can you find there?…

    • 565 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The expression 1 To 5 in the Case 1 To 5 clause specifies the range of numbers from ____.…

    • 595 Words
    • 3 Pages
    Satisfactory Essays
  • Better Essays

    E-Commerce Exercise

    • 1068 Words
    • 5 Pages

    3. The String class ____ method evaluates the contents of two String objects to determine if they are equivalent.…

    • 1068 Words
    • 5 Pages
    Better Essays
  • Good Essays

    7. Although in some programs a While statement should be infinite, in most programs a While statement should eventually end. How can you make sure that a While statement will eventually end?…

    • 610 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    4. Build the Program using build option and check for any errors (correct if any) (this step generates a source file with extension .s19).…

    • 328 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Homeos

    • 369 Words
    • 2 Pages

    Write a shell-like program that illustrates how LINUX spawns processes. This simple program will provide its own prompt to the user, read the command from the input and execute the command. It is sufficient to handle just argument-less commands, such as ls and date.…

    • 369 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Woooo!

    • 982 Words
    • 4 Pages

    #include <stdlib.h> #include <stdio.h> #include <string.h> #include "dynamicArray.h" #include <assert.h> /* param: s the string * param: num a pointer to double * returns: true (1) if s is a number else 0 or false. * postcondition: if it is a number, num will hold *…

    • 982 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    1. a. The PC contains 300, the address of the first instruction. This value is loaded…

    • 15908 Words
    • 64 Pages
    Powerful Essays
  • Satisfactory Essays

    Hi Everyone.

    • 326 Words
    • 2 Pages

    * You have to tell the computer, step by step, exactly what you want it to do. The computer then “executes" the program, following each step to accomplish the end goal.…

    • 326 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    /Contiguous file allocation/ #include<stdio.h> Int main() { char a[10][10]; int I,flb[10],sb[10]; for(i=1;i<=5;i++) { printf(“\nEnter the file name:”); scanf(“%s”,&a); printf(“\nEnter the starting block:”); scanf(“%d”,&sb[i]); printf(“\nEnter the file length in blocks:”); scanf(“%d”,&flb[i]); } printf(“\n\nList of files\tstarting block\tfile length”); for(i=0;i<5;i++) { printf(“\n%s\t%d\t%d”,a[i],sb[i],flb[i]); } return 1; } /indexed allocation/ #include<stdio.h> int main() { char a[10]; int i,1.b,a.b[10]; srintf(“\nEnter the file name:”); Scanf(“%d”,&a); printf(“\n\nIndexed block:”); scanf(“%”,&ib); for(i=1;i<5;i++){ printf(“\nEnter the child of index block%d:”,i); scanf(“%d”,&c I b[i]); } printf(“\n\n\nThe list of files\t index block”); printf(“\n\n%s\t%d”,a,ib); printf(“\n\nThe above file utilization index block of child following!\n\n\t”); for(i=1;i<=5;i++){ printf(“%d\t”,c I b[i]); } return 1; } /linked allocation/ #include<stdio.h>…

    • 317 Words
    • 2 Pages
    Good Essays
  • Better Essays

    Pointer and Stack

    • 1257 Words
    • 6 Pages

    Here, type is the pointer's base type; it must be a valid C data type and var-name is the name of the pointer variable. The asterisk * you used to declare a pointer is the same asterisk that you use for multiplication. However, in this statement the asterisk is being used to designate a variable as a pointer. Following are the valid pointer declaration:…

    • 1257 Words
    • 6 Pages
    Better Essays
  • Good Essays

    Compiler Construction

    • 376 Words
    • 3 Pages

    Interpreter-a program that reads an executable program and produces the results of running that program…

    • 376 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Tets

    • 2487 Words
    • 10 Pages

    • The CPU executes one instruction of the process after another, until the process is complete. At most one instruction is executed on behalf of the process. Therefore, although two processes may be associated with the same program, they are nevertheless considered two separate execution sequences. It is common to have a program that spawns many processes as it runs.…

    • 2487 Words
    • 10 Pages
    Powerful Essays