C PROGRAMMING
MULTIPLE CHOICE QUESTION
OLD QUESTION BANK
SAMPLE QUESTION 2080 AND SOLUTION

LAB 2 

After this lab students will learn use operators and formatted /unformatted input output. No need to write algorithms and draw flowchart.

  1. WAP  to read two numbers from the user and determine the larger number using a conditional operator.
  2. WAP to calculate the number of memory bytes required for an int,float,double and char type variable . 
  3. WAP to read a string with multiple words(i.e. With space ) using scanf function and display.
  4. Write a program that uses functions:
  1. scanf()  // use[A-Z] inside scanf
  2. printf()
  3. getchar()
  4. putchar()
  5. gets()
  6. puts()

5. Write the output of following program and also explain about each output: 

#include<stdio.h>

int main()

{

int n=1234;

char ch='A';

char str[10]="Hello World";

printf("1.n=%-6d\n",n);

printf("2.n=%6d\n",n);

printf("3.ch=%-5c\n",ch);

printf("4.ch=%5c\n",ch);

printf("5.string is:%10s\n",str);

printf("6.string is:%10.8s\n",str);

printf("7.string is:%-10.8s\n",str);

return 0:

}