Tech Mahindra Placement Paper 1. C-Test Paper. 1. #include. * What is wrong in the following problem. main() { int i,j; j = 10;

Similar documents
COP 3223 Introduction to Programming with C - Study Union - Fall 2017

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

COP 3223 Introduction to Programming with C - Study Union - Spring 2018

'C' Programming Language

Essar Placement Paper

CS 0449 Sample Midterm

MTH 307/417/515 Final Exam Solutions

Fundamentals of Programming Session 19

Please note that, for all What will be output questions, the answer could be error or indefinite. However, there is no compile error.

Bil 104 Intiroduction To Scientific And Engineering Computing. Lecture 7

Introduction to Programming

SOFTWARE Ph.D. Qualifying Exam Spring Consider the following C program which consists of two function definitions including the main function.

What will the output of the following code snippet be? Why? What is a safer alternate implementation?

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015

Fundamentals of Programming Session 20

Engineering 12 - Spring, 1998

Learning C Language. For BEGINNERS. Remember! Practice will make you perfect!!! :D. The 6 th week / May 24 th, Su-Jin Oh

Name Roll No. Section

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER

Computer Programming 6th Week Functions (Function definition, function calls),

Storage class and Scope:

C Multiple Choice Questions and answers MCQ with Ans.

C Programming. The C Preprocessor and Some Advanced Topics. Learn More about #define. Define a macro name Create function-like macros.

Make sure the version number is marked on your scantron sheet. This is Version 1

Fundamental of Programming (C)

Functions Introduction to Algorithms and Programming II School of Computer Science Term: Summer 2013 Instructor: Dr. Asish Mukhopadhyay

16.216: ECE Application Programming Fall 2011

Final Intro to C Review

Unit 1 - Arrays. 1 What is an array? Explain with Example. What are the advantages of using an array?

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

Structured Programming. Functions and Structured Programming. Functions. Variables

Principles of C and Memory Management

Fundamentals of Programming

M.EC201 Programming language

Fundamental of Programming (C)

Basic Assignment and Arithmetic Operators

Fundamentals of Programming Session 14

Arrays and Pointers (part 2) Be extra careful with pointers!

2. Which of the following will print the value 2 for the above code?

Arrays and Pointers (part 2) Be extra careful with pointers!

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

UNIT 1: POINTERS & DYNAMIC MEMORY ALLOCATION. Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru.

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

Important From Last Time

Page 1. Today. Important From Last Time. Is the assembly code right? Is the assembly code right? Which compiler is right?

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

{C} Programming. Part 1/2 Basics Variables, Conditions, Loops, Arrays, Pointer basics

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

Q 1. Attempt any TEN of the following:

Important From Last Time

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #06

Chapter 11 Introduction to Programming in C

Structured programming

2. C99 standard guarantees uniqueness of characters for internal names. A. 12 B. 26 C. 31 D. 48

Introduction to Computing Lecture 07: Repetition and Loop Statements (Part II)

CS360 Midterm 1 - February 21, James S. Plank. Put all answers on the answer sheet. In all of these questions, please assume the following:

Introduction to Programming

Renault Nissan Placement Paper Part-1

Chapter 11 Introduction to Programming in C

공학프로그래밍언어 (PROGRAMMING LANGUAGE FOR ENGINEERS) -CONTROL FLOW : LOOP- SPRING 2015, SEON-JU AHN, CNU EE

Functions. Autumn Semester 2009 Programming and Data Structure 1. Courtsey: University of Pittsburgh-CSD-Khalifa

Control flow and string example. C and C++ Functions. Function type-system nasties. 2. Functions Preprocessor. Alastair R. Beresford.

Memory Allocation. General Questions

C Language Summary (Continued)

A First Book of ANSI C Fourth Edition. Chapter 12 Structures

Recursion. Data and File Structures Laboratory. DFS Lab (ISI) Recursion 1 / 20

Structures in C. C allows you to declare a struct. Once you do so, you can create variables of this type. Here is the general syntax:

Imperative Programming

Assoc. Prof. Dr. Tansu FİLİK

Write a C program using arrays and structure

High Performance Programming Programming in C part 1

CS 161 Intro to CS I. Finish Pointers/Start Recursion

The output will be: marks all or nothing. 1 #include <stdio.h> 2 main() { 3 int i; int j; 4 int *p; int *q; 6 p = &i; 7 q = &j; 8 i = 1;

F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C

Example: Structure, Union. Syntax. of Structure: struct book { char title[100]; char author[50] ]; float price; }; void main( )

Subject: PIC Chapter 2.

Chapter 8. Arrays, Addresses, and Pointers : Structured Programming Structured Programming 1

Chapter 11 Introduction to Programming in C

Structured programming

{ int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } A. Function addmult() return 7 and 12 B. No output C. Error: Compile error D.

These problems are provided to you as a guide for practice. The questions cover important concepts covered in class.

Library Functions. General Questions

Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size];

Chapter 11 Introduction to Programming in C

Hacking C Code - Local Machine

Procedural programming with C

Programming in C++: Assignment Week 2

Applied Programming and Computer Science, DD2325/appcs15 PODF, Programmering och datalogi för fysiker, DA7011

Government Polytechnic Muzaffarpur.

COMP 2355 Introduction to Systems Programming

Pointers, Arrays, and Strings. CS449 Spring 2016

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

Chapter 11 Introduction to Programming in C

C PROGRAMMING Lecture 4. 1st semester

SOFTWARE Ph.D. Qualifying Exam Fall 2017

Solution for Data Structure

Practice problems Set 2

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

Transcription:

Tech Mahindra Placement Paper 1 C-Test Paper 1. #include * What is wrong in the following problem int i,j; j = 10; i = j++ - j++; printf("%d %d", i,j); ans: 0, 12 2.#include * What is the output of the following problem int j; for(j=0;j<3;j++) foo(); foo() static int i = 10; i+=10; printf("%d\n",i); /* Out put is (***since static int is used i value is retained between * 20 function calls ) * 30 * 40 * / 3.#include #include #include /* This is asked in PCS Bombay walk-in-interview

* What is wrong in the following code char *c; c = "Hello"; printf("%s\n", c); /*ans:- Hello, The code is successfully running 4. #include /* This problem is given in PCS BOMBAY walk- in-interview. * What is the final value of i and how many times loop is * Executed? int i,j,k,l,lc=0; /* the input is given as 1234 567 printf("enter the number string:<1234 567 \n"); scanf("%2d%d%1d",&i,&j,&k); for(;k;k--,i++) for(l=0;l printf("%d %d\n",i,l); printf("loops= %d\n", lc- 1); /* Ans: i = 16, and loop is executed for 169 times 5.#include

/* This is given in PCS Bombay walk-in-interview /* What is the output of the following program union int a; int b; int c; u,v; u.a = 10; u.b = 20; printf("%d %d \n",u.a,u.b); /* Ans : The latest value assigned to any of the union member will be present in the union members so answer is 20 20 6.#include float i, j; scanf("%f %f", &i, &j); printf("%.2f %.3f", i, j); /Ans:- 123.34 3. 234 7.#include /* This is given in PCS Bombay walk-in-interview * What is the out put of the following problem? char *str = "12345"; printf("%c %c %c\n", *str, *(str++), *(str++)); /* Ans: It is not 1 2 3 * But it is 3 2 1 Why?? 8.#include

/* This problem is asked in PCS Bombay Walk-in- interview * Write a macro statement to find maximum of a,b #define max(a,b) (ab)?a:b int a,b; a=3; b=4; printf("%d",max(a,b)); /* Ans is very simple the coding is just for testing it and output is 4 ~ 9.#include /* This problem is asked in PCS Bombay * What is the output of the following coding int len=4; char *st="12345678"; st = st -len; printf("%c\n",*st); /* Ans : It will print some junk value ~ 10.#include func(1); func(int i)

static char *str = "One","Two","Three","Four"; printf("%s\n",str[i++]); return; /* Ans:- it will give warning because str is pointer to the char but it is initialized with more values if it is not considered then the answer is Two 11. #include int i; for (i=1;i<100; i++) printf("%d %0x\n",i,i); /* Ans:- i is from 1 to 99 for the first format, for the second format 1to9, ato f, 10 to 19,1ato1f, 20 to 29, etc 12.#include /* This problem is asked in PCS Bombay walk-in- interview * In the following code please write the syntax for * assing a value of 10 to field x of s and id_no 101 of s struct int x; int y; union int id_no; char *name; b; s,*st;

st = &s; st-x=10; st-b.id_no = 101; printf("%d %d\n",s..x,s.b.id_no); /* Ans: The answer is st-x=10; * st-b.id_no=101; 13.#include /* This problem was asked in PCS Bombay in a walk-in-interview * Write a recursive function that calculates * n * (n-1) * (n-2) *... 2 * 1 int factorial(int n); int i,ans; printf("\n Enter a Number:"); scanf("%d",&i); ans = factorial(i); printf("\nfactorial by recursion = %d\n", ans); int factorial(int n) if (n <= 1) return (1); else return ( n * factorial(n-1)); ~ 14.#include /* This problem is asked in PCS Bombay walk-in- interview * What is the output of the following

problem int j,ans; j = 4; ans = count(4); printf("%d\n",ans); int count(int i) if ( i < 0) return(i); else return( count(i-2) + count(i-1)); /* It is showing -18 as an answer 15.#include int i=4; if(i=0) printf("statement 1"); else printf("statement 2"); /* statement 2 This is pcsb paper. 1. #include * What is wrong in the following problem int i,j; j = 10; i = j++ - j++; printf("%d %d", i,j); ans: 0, 12 2.#include * What is the output of the following problem

int j; for(j=0;j<3;j++) foo(); foo() static int i = 10; i+=10; printf("%d\n",i); /* Out put is (***since static int is used i value is retained between * 20 function calls ) * 30 * 40 * / 3.#include #include #include /* This is asked in PCS Bombay walk-in-interview * What is wrong in the following code char *c; c = "Hello"; printf("%s\n", c); /*ans:- Hello, The code is successfully running 4. #include /* This problem is given in PCS BOMBAY walk- in-interview. * What is the final value of i and how many

times loop is * Executed? int i,j,k,l,lc=0; /* the input is given as 1234 567 printf("enter the number string:<1234 567 \n"); scanf("%2d%d%1d",&i,&j,&k); for(;k;k--,i++) for(l=0;l printf("%d %d\n",i,l); printf("loops= %d\n", lc- 1); /* Ans: i = 16, and loop is executed for 169 times 5.#include /* This is given in PCS Bombay walk-in-interview /* What is the output of the following program union int a; int b; int c; u,v; u.a = 10; u.b = 20; printf("%d %d \n",u.a,u.b); /* Ans : The latest value assigned to any of the union member will be present in the union members so answer is 20 20 6.#include

float i, j; scanf("%f %f", &i, &j); printf("%.2f %.3f", i, j); /Ans:- 123.34 3. 234 7.#include /* This is given in PCS Bombay walk-in-interview * What is the out put of the following problem? char *str = "12345"; printf("%c %c %c\n", *str, *(str++), *(str++)); /* Ans: It is not 1 2 3 * But it is 3 2 1 Why?? 8.#include /* This problem is asked in PCS Bombay Walk-in- interview * Write a macro statement to find maximum of a,b #define max(a,b) (ab)?a:b int a,b; a=3; b=4; printf("%d",max(a,b)); /* Ans is very simple the coding is just for testing it and output is 4 ~ 9.#include

/* This problem is asked in PCS Bombay * What is the output of the following coding int len=4; char *st="12345678"; for(i=0; i<6; i++) st = st -len; printf("%c\n",*st); /* Ans : It will print some junk value ~ 10.#include func(1); func(int i) static char *str = "One","Two","Three","Four"; printf("%s\n",str[i++]); return; /* Ans:- it will give warning because str is pointer to the char but it is initialized with more values if it is not considered then the answer is Two 11. #include int i; for (i=1;i<100; i++) printf("%d %0x\n",i,i);

/* Ans:- i is from 1 to 99 for the first format, Naradha.in Naradha.in for the second format 1to9, ato f, 10 to 19,1ato1f, 20 to 29, etc 12.#include /* This problem is asked in PCS Bombay walk-in- interview * In the following code please write the syntax for * assing a value of 10 to field x of s and id_no 101 of s struct int x; int y; union int id_no; char *name; b; s,*st; st = &s; st-x=10; st-b.id_no = 101; printf("%d %d\n",s.x,s.b.id_no); /* Ans: The answer is st-x=10; * st-b.id_no=101; 13.#include /* This problem was asked in PCS Bombay in a

walk-in-interview * Write a recursive function that calculates * n * (n-1) * (n-2) *... 2 * 1 int factorial(int n); int i,ans; printf("\n Enter a Number:"); scanf("%d",&i); ans = factorial(i); printf("\nfactorial by recursion = %d\n", ans); int factorial(int n) if (n <= 1) return (1); else return ( n * factorial(n-1)); ~ 14.#include /* This problem is asked in PCS Bombay walk-in- interview * What is the output of the following problem int j,ans; j = 4; ans = count(4); printf("%d\n",ans); int count(int i) if ( i < 0) return(i); else return( count(i-2) + count(i-1));

/* It is showing -18 as an answer 15.#include int i=4; if(i=0) printf("statement 1"); else printf("statement 2"); /* statement 2